saving matlab results
조회 수: 4 (최근 30일)
이전 댓글 표시
hi there, anyone know hot to save results to a file in matlab? suppose i had this x,y,z data that i want to save it as results.str that is openable via matlab. anyone can help? thank you very much
댓글 수: 0
채택된 답변
Jan
2011년 5월 4일
"Put z inthe first column" is not an exact definition of the output. Do you want to write an ASCII file?
FID = fopen(FileName, 'w');
if FID < 0, error(Cannot open file); end
data = [z, y, x];
fprintf(FID, '%g %g %g\n', transpose(data));
fclose(FID);
See "help fprintf", if you want to specify another numerical format, e.g. more digits after the dot.
댓글 수: 2
Jan
2011년 5월 4일
@Win: Simply read "help fopen" to see, what this command does: " 'w' open file for writing; discard existing contents".
FWRITE writes binary data, FPRINTF writes ASCII data. Both could solve your problem, it only depends on your needs. If the file need not be readable by human, a binary format is more efficient. How is the ".str" format defined?!
추가 답변 (1개)
Andreas Goser
2011년 5월 4일
From your description, I'd say you have x, y, z in your MATLAB workspace. Then you can save the data with the SAVE command. The default is a so called MAT file, but you can also choose the ASCII format. See the documentation for that.
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!