Is it possible to evaluate symbolic functions from an array?

4 Ansichten (letzte 30 Tage)
Max
Max am 26 Nov. 2014
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.

Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by