Borrar filtros
Borrar filtros

Hou to substitute a variable

1 visualización (últimos 30 días)
Nadia Bica
Nadia Bica el 24 de Abr. de 2015
Respondida: Star Strider el 24 de Abr. de 2015
Hello on the file that is attached I want to substitute a variable called My by the result of momento so then all the operations where My is used start to use the output of momento. I tried subs(My,momento) but it didnt work. All the operations still have My. Thank you.
  2 comentarios
Mischa Kim
Mischa Kim el 24 de Abr. de 2015
There is no file attached.
Stephen23
Stephen23 el 24 de Abr. de 2015
@ Nadia Bica: to upload a file you need to click the paperclip button, and then push both buttons: Choose file and Attach file.

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 24 de Abr. de 2015
The subs function needs three arguments. You have to tell subs the expression you want to substitute your variables in. That is the part you did not state in your subs call.
For example (assuming that you want to substitute ‘momento’ for ‘My’ in a function I call ‘F’ here):
syms x y My
F = x + y + My;
momento = x*y;
F = subs(F, My, momento)
produces:
F =
x + y + x*y

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by