saving the output of diff function to a variable

hello
i am working on GUI project i have a case that i want to use diff function in the project
the output of diff funtion is supposed to be displayed or calledback in other things
the problem is i canot find a way to save the output of th diff function to a varriable to be used later
i know that when i write >> diff x^2 ans =
2*x
what i want is to save the ans to variable in the GUI
thanks in advance nour r

Respuestas (2)

Paulo Silva
Paulo Silva el 12 de Feb. de 2011
%In your workspace do this
MyVariable=diff('x^2');
%In your GUI do this
MyVariable = evalin('base', 'MyVariable');
%MyVariable will be a symbolic expression, if you want it in string format
MyVariable=char(MyVariable) %convert it to a string
%Converts to string but also inserts a . before any ^, * or / in s
%MyVariable=vectorize(MyVariable)

Etiquetas

Preguntada:

el 12 de Feb. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by