I have defined an array of anonymous functions in side a function as shown below.
function test(x,y)
f={@(x,y) (3*y*x^2)
@(x,y) (x*y)
@(x,y) (x*2*y^2)
@(x,y) (2*x*y)}
res2=f{2}(x,y)-2*f{1}(x,y)
res3=f{3}(x,y)-5*f{2}(x,y)
res4=f{4}(x,y)-4*f{2}(x,y))
end
I want to obtain a 3 by 10 matrix via
x=2
y=linspace(0.0001,0.001,10)
for i=1:length(y)
final(i)=test(x,y(i));
end
However, I get an error stating there are too many input variables. How could I correct this?
testto return three values? Make it return a 3-value vector, then sayfinal(:,i)=test(x,y(i)). And do preallocatefinal!