MATLAB: Save Sym data per variable

savesymbolic

Hello, I have a code which deals with symbolic variables and I have as output a vector whose dimension is known but variable.
The output is symbolic, for example a=[y_1/3+y_2/5 y_1/10+y_2/37]
I would like to save in an ASCII file, not binary, the output and for each row have one element of the vector. The tricky part is the saving in a file, I can do it only in bin, since when I type -ASCII it doesn't do it.
Here I attach a piece of code useful to understand. Thanks for your time.
Antonio
syms a b c x;
results=solve('a*x^2 + b*x + c');
save results.dat results
My output comes as:
results=[-(b + (b^2 – 4*a*c)^(1/2))/(2*a) -(b – (b^2 – 4*a*c)^(1/2))/(2*a)]

Best Answer

One may use DIARY( http://www.mathworks.com/help/releases/R2011b/techdoc/ref/diary.html ) to capture any output to the command window into a text file.
Otherwise, you may convert your symbolic variables into strings and write them into a text file, for instance:
syms a b c x;
results=solve('a*x^2 + b*x + c');
fid = fopen('myfile.txt', 'w');
fwrite(fid, char(results), 'char');
fclose(fid);
Hope this helps.
Abhi...