Export numeric multidimensional array
이전 댓글 표시
Hi All I have an MxMxT numeric array. Is it possible to export it in txt format?
Thank you, Veni
답변 (2개)
Yes, why not. The question is only, which kind of format you want. E.g. this is simple:
A = rand(3,4,5);
File = fullfile(YourFolder, 'Output.txt');
fid = fopen(File, 'r');
if fid == -1, error('Cannot open file: %s', File);
fprintf(fid, '%g\n', A);
fclose(fid);
Then you get a single column of values. The information about the original dimension is lost. So perhaps you want to insert the array size as first line? Or you can create a file with M columns. Perhaps you want to insert a blank line after each MxM sub-matrix. This is up to you. The more details you specify, the more complicated is the function to import the data.
Note that text files are useful, if a human has to edit it. In all other cases binary files are better.
veni
2015년 12월 28일
댓글 수: 2
Steven Lord
2015년 12월 29일
My guess is that you don't have write permission in that directory. To check this, try to write to a file in your TEMPDIR.
Jan
2015년 12월 29일
@veni: Please explain the wanted format for the file and if you really need a text file.
카테고리
도움말 센터 및 File Exchange에서 Other Formats에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!