My generic problem is illustrated by the following example:
f=@(x,y) cos(x.*y);
Yvalues = linspace(0,1,50);
W = @(x) f(x,Yvalues);
which works fine if I only want to evaluate W at one point at a time. For instance:
norm(W(pi/3)-f(pi/3,Yvalues))
ans =
0
But how do I go about evaluating W at any number of points?
Thanks in advance.
Yvalueswhen you wrotex? Also, the norm of a vector is by definition scalar (it's the "length" of the vector), so the fact that your second code snippet is returning an expected value. Note thatW(pi/3)-f(pi/3, Yvalues)returns a row of 50 zeros. As long as the input toWis the same length asYvalues,Wreturns a vector.