Is it possible to evaluate symbolic functions from an array?

4 views (last 30 days)
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.

Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!