Saving data on .m file

The homework question orders me to save my datas on .m file, without replacing the previous saved datas. i saved it as per the question and i see some kind of parse error
Can i get rid of it?

Answers (1)

That is not necessarily an error. The data could be retrieved from the file by using load() or readmatrix()
You would not typically save data to a .m file as .m files are normally for executable code.
If the expectation is that you are to create executable code, then you need to save the data in the form of an assignment statement. Something like
fid = fopen(etc etc);
fprintf(fid, 'ag = [\n');
now fprintf a and g
fprintf(fid, '];\n');
You would then do something similar for a1 g1, except giving it a different variable name, such as 'a1g1 = '

Asked:

on 15 Dec 2021

Answered:

on 15 Dec 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!