How to print an array to a .txt file in Matlab?

后端 未结 1 1282
轻奢々
轻奢々 2021-02-14 11:59

I am just beginning to learn Matlab, so this question might be very basic:

I have a variable

a=[2.3 3.422 -6.121 9 4.55]
相关标签:
1条回答
  • 2021-02-14 12:35

    The following should do the trick:

    fid = fopen('c:\\coeffs.txt','wt');  % Note the 'wt' for writing in text mode
    fprintf(fid,'%f\n',a);  % The format string is applied to each element of a
    fclose(fid);
    

    For more info, check out the documentation for FOPEN and FPRINTF.

    0 讨论(0)
提交回复
热议问题