How to use subs with sym
1 次查看(过去 30 天)
显示 更早的评论
Dear All,
I have the following code:
clc
clear all
close all
f=@(x,y)x^2+y;
f=sym(f);
out=subs(f,x,2)
Could you please tell me what should I do to prevent getting an error.
Thanks a lot.
0 个评论
采纳的回答
Mischa Kim
2015-3-17
hadi, you need to define x as a symbolic variable
syms x y
f = @(x,y) x^2 + y;
f = sym(f);
out = subs(f,x,2)
out =
y + 4
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!