How to use subs with sym

4 ビュー (過去 30 日間)
hadi
hadi 2015 年 3 月 17 日
コメント済み: hadi 2015 年 3 月 17 日
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.

採用された回答

Mischa Kim
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
  1 件のコメント
hadi
hadi 2015 年 3 月 17 日
Thank you so much I really appreciate your help.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by