How to save a matrix output to a text file that located in different folder?
26 views (last 30 days)
Abdulaziz Abutunis on 16 Sep 2017
I want to save a matrix output (My_matrix ) to a text file (scaled_1.txt) that located in different folder than the script (.m file).
I have tried
fid = fopen('F:\output\scale\scaled_1.txt', 'w');
fprintf(fid, '%s\n', ' My_matrix ');
This will only print the text (My_matrix ) and not the content of the matrix.
I appreciate your suggestions in advance
Walter Roberson on 16 Sep 2017
filename = 'F:\output\scale\scaled_1.txt';
arrayname = 'My_matrix';
fid = fopen(filename, 'w');
fprintf(fid, ' %s \n', arrayname);
save(filename, arrayname, '-ascii', '-double', '-append');