Problem save

조회 수: 6 (최근 30일)
Jose Luis
Jose Luis 2011년 2월 24일
Hello, I have a very simple question. I want to save a variable of the workspace as an ascii file. I make the following request ("a" is a int16 variable):
save a.txt a -ascii
but I get the following message
Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'seriesb' not written to file.
The variables stocked as int16 are not supported by the "save" command? I want to save my variables as int16 and not double ( because I don't want waste too much space), or the same I want just numbers without digits... what should I do?
thank you very much for your help

채택된 답변

Jan
Jan 2011년 2월 24일
If you do not want to waste too much space (what does the GB diskspace cost at the moment?), save your data in binary format, not in -ASCII. Then an int16 needs 2 bytes. As ASCII the int16 -32768 needs 6 bytes plus a delimiter!
What are numbers without digits? Do you mean integers?
Perhaps it is better to use DLMWRITE or FPRINTF to write your files. Then you have more control over the format.

추가 답변 (1개)

Matt Tearle
Matt Tearle 2011년 2월 24일
If you want ascii, why not just write out using fprintf?
fid = fopen('a.txt','wt');
fprintf(fid,'%hd\n',a);
fclose(fid);
  댓글 수: 6
Jan
Jan 2011년 2월 24일
@Matt: ? I meant, that Jose would benefit from reading the Getting Started chapters.
Matt Tearle
Matt Tearle 2011년 2월 24일
Gah, we need threaded comments! That was in reply to "What is the %hd format?"

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by