how to define a vector of functions using a for cycle?
Ältere Kommentare anzeigen
I have defined n functions fi(t,x,y),
I want to obtain the vector:
F=@(t,x,y) [f1(t,x,y); f2(t,x,y); ... fn(t,x,y)],
without writing the vector by hand but implementing a cycle like:
for i=1:n
fi=@(t,x,y) x+3*i*y+t^2
F(i)=fi
end
3 Kommentare
Daniel M
am 10 Okt. 2019
Does this help? If not, you'll have to clarify a bit more of what you are specifically trying to do (and trying to avoid doing).
funcList = {@f1,@f2,@fn};
for f = 1:length(funcList)
output{f} = funcList{f}(t,x,y);
end
Shubham Gupta
am 10 Okt. 2019
Maybe this will help?
F = @(t,x,y)[];
for i=1:n
fi=@(t,x,y) x+3*i*y+t^2
F=@(t,x,y)[F(t,x,y);fi(t,x,y)];
end
Luca Losero
am 16 Okt. 2019
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!