How to use subs with sym

2 visualizaciones (últimos 30 días)
hadi
hadi el 17 de Mzo. de 2015
Comentada: hadi el 17 de Mzo. de 2015
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.

Respuesta aceptada

Mischa Kim
Mischa Kim el 17 de Mzo. de 2015
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 comentario
hadi
hadi el 17 de Mzo. de 2015
Thank you so much I really appreciate your help.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by