Problem save
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
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
2011 年 2 月 24 日
What is the %hd format?
Jose Luis
2011 年 2 月 24 日
Jan
2011 年 2 月 24 日
'a.txt' is not a variable, but a string. It is the name of the output file. And you write the variable "a" into the file. Just try it and you will see, what happens. The questions about FOPEN are very basic, so I suggest to read the "Getting Started" chapters of the documentation.
Matt Tearle
2011 年 2 月 24 日
@Jan: according to the doc, it's a signed integer "16-bit base 10 values". Not having really used uint16s for anything, I don't know any more than that, but it sounds like the right format!
@Jose: see Jan's reply. That code does exactly what "save a.txt a -ascii" would do if int16 was a supported type (ie write the variable "a" to an ascii file "a.txt" using an integer format.
Jan
2011 年 2 月 24 日
@Matt: ? I meant, that Jose would benefit from reading the Getting Started chapters.
Matt Tearle
2011 年 2 月 24 日
Gah, we need threaded comments! That was in reply to "What is the %hd format?"
カテゴリ
ヘルプ センター および File 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!