MATLAB: Save long symbolic variable as .txt

MATLABsymbolictext file

Hi, I have a symbolic variable containing the golden ratio with a 1000000 digits precision. How do I save this into a .txt file?
Thank you in advance!

Best Answer

  • Let x be your symbolic variable.
    fid = fopen('test.txt', 'wt');
    fprintf(fid, '%s\n', char(x));
    fclose(fid);