MATLAB: Undefined operator ‘:’ for input arguments of type ‘function_handle’

errorfunction handleundefined operator

Hey,
I keep getting this message and have no idea whats wrong. It has something to do with the ymax function, this I know.
Undefined operator ':' for input arguments of type 'function_handle'
code
h=1;
x=[0:h:10];
ymax= @ (xx)5.*sin(pi.*xx./10);
y=[0:h:ymax] ;
[xx,yy]=ndgrid(x,y);
mat = exp(-0.25.*((xx-8).^2 + (yy-0).^2)) .*cos((xx-8-yy)/6);
b{1}=x; b{2}=y;
T=Trapets(b,mat,2);
Grateful for all help recieved.

Best Answer

You need to give ‘ymax’ an argument, so it returns a value.
This works:
ymax= @(xx) 5.*sin(pi.*xx./10);
h = 1;
y=[0:h:ymax(2)];