The eval command as a string for use with Matlab

Is there a way in Matlab to save the command as a string for later use?
For example, if I have

x = 1:10;
plot(x, x);

Can I somehow save the 2nd line as str = 'plot(1:10, 1:10)'automatically, so that later I can use the command again with eval(str)? Any useful features to help me cope with this task?

ps I know that it is possible to save a string with str='plot(x,x)', but this is not good enough, because it depends on the instantaneous values ​​of the workspace variable x, which can change over time.

+3
source share
1 answer

. :

x=1:10;
f = @()plot(x, x);

f , ( x), :

f()
+6

All Articles