Is it possible to evaluate symbolic functions from an array?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
My idea was to simplify the working code
syms x y
f1(x,y) = x + y;
f2(x,y) = x * y;
A = [ [1,2]', [3,4]' ];
H = A(:,1) * f1(x,y) + A(:,2) * f2(x,y);
by using:
syms x y
f1(x,y) = x + y;
f2(x,y) = x * y;
F = [f1, f2];
A = [ [1,2]', [3,4]' ];
H = 0;
for i = 1 : length(A)
H = H + A(:,i) * F(i)(x,y);
end
Unfortunately, the term F(i)(x,y) gives rise to the error
Cannot call or index into a temporary array
Given that the actual code uses much larger matrices and functions, writing out the summation of H becomes a pain in the neck. I would appreciate any hint which would allow me to automatize the process.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!