How to save a structure array to a text file

后端 未结 3 1773
走了就别回头了
走了就别回头了 2020-12-18 03:07

In MATLAB how do I save a structure array to a text file so that it displays everything the structure array shows in the command window?

3条回答
  •  失恋的感觉
    2020-12-18 03:52

    To convert any data type to a character vector as displayed in the MATLAB command window, use the function

    str = matlab.unittest.diagnostics.ConstraintDiagnostic.getDisplayableString(yourArray);
    

    You can then write the contents to a file

    fid = fopen('myFile.txt', 'w'); 
    fwrite(fid, str, '*char');
    fclose(fid);
    

提交回复
热议问题