Possible Duplicate:
How to save contents of MATLAB’s command windows to in a file?
Using function pretty(x)
I get what I want in command window. I need to get the same in text file. How to do this?
Possible Duplicate:
How to save contents of MATLAB’s command windows to in a file?
Using function pretty(x)
I get what I want in command window. I need to get the same in text file. How to do this?
I think that the best way is to use the clc disp() and char() commands:
clc % clear the command window
syms x y;
expression = x*y; % make your calculations
expression2 = x+y;% make your calculations
% make your calculations
disp(char(expression)) % char() converts symbolic expression to string
disp(char(expression2))% and disp() shows the string in the command window
You can copy everything in the command window really fast with the normal windows commands ctrl+a (select all), ctrl+c (copy) and ctrl+v (paste).
Hope this helps
You can use the command evalc to redirect all output that would go to the console to a string variable (which you later can save to a file).
E.g.:
>> a = sym('a'); b = sym('b');
>> str = evalc('pretty(a+b)');
>> str
str =
a + b