saving the output of diff function to a variable

1 view (last 30 days)
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

Answers (2)

Paulo Silva
Paulo Silva on 12 Feb 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)

Walter Roberson
Walter Roberson on 12 Feb 2011
Please see the FAQ on this topic

Categories

Find more on Projects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!