MATLAB: Save syms into a file txt

syms txt file

a have a function like that
>> syms t
>> f = sin(t)
i want to save f into file .txt. Example name of file is a.txt with it's content: sin(t)
how to do that. Help and guide me.
Tk a lot.

Best Answer

fid = fopen('a.txt', 'wt');
fprintf(fid, '%s\n', char(f));
fclose(fid);
Note: char() of a symbolic expression does not generally result in a string that can be evaluated by MATLAB. char() of a symbolic expression is really only suitable for entering the expression back in to the symbolic toolbox.