Symbolic expressions inside of array

syms x
f(x) = x^2;
g(x) = x^3;
a = [f,g];
Imagine I have a code like this, and I wish to evaluate only f for a certain value, but not bring outside of the array. How can I do this? For instance, if now ask for a(3), matlab will output [9,27]. However, I want only want 9.

 Accepted Answer

syms x y
f = x^2;
g = y^3;
a = [f,g];
subs(a,x,3);

2 Comments

You answer gives me the output [9, y^3], whereas I want merely 9
Never mind subs(a(1),x,3) gives the answer, thanks!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!