Symbolic expressions inside of array

1 次查看(过去 30 天)
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.

采纳的回答

David Hill
David Hill 2021-4-14
syms x y
f = x^2;
g = y^3;
a = [f,g];
subs(a,x,3);
  2 个评论
Bram van Eijnatten
Bram van Eijnatten 2021-4-14
You answer gives me the output [9, y^3], whereas I want merely 9
Bram van Eijnatten
Bram van Eijnatten 2021-4-14
Never mind subs(a(1),x,3) gives the answer, thanks!

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by