I'm learning MATLAB and for my homework am supposed to use the diary feature to save a file from the command window. I used the following code,
%% 2.21
clc
clear
diary( 'degrees.dat' )
columnOne = linspace(0, 180, 8);
columnTwo = columnOne .* (pi / 180);
D_to_R = [columnOne', columnTwo']
diary off
clc
clear
load ( 'degrees.dat' )`
and got the error:
Error using load Number of columns on line 3 of ASCII file degrees.dat must be the same as previous lines.
I put the above code in the editor window but tried putting it directly in the command window and it didn't make a difference. The code up until loading the saved file seems to work fine and I can't see a difference in number of columns like the error indicates. Any ideas?
diaryputs all text from the command window in an ASCII file.loadis used for loading variables, typically from a file in.matformat, or optionally from ASCII with a specific format, which is not what you get in your diary file. The diary file is not normally meant to be processed by Matlab. What did you expectload('degrees.dat')to do? - Luis Mendo