필터 지우기
필터 지우기

How I save my variable into text file?

조회 수: 14 (최근 30일)
Nora Hora
Nora Hora 2016년 10월 29일
댓글: Nora Hora 2016년 10월 29일
I have a problem during saving my variable. When I run my code I receive a value (249336x4 int16). If I open it in MATLAB I see all the numbers and everything is good. Then I use the command: save('result.txt','result'); But in the .txt file when I open I dont get the same numbers but some text which is not understandable. I also tried to save like this: save('result.txt', 'result', '-ASCII'); But I receive a message: "Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'result' not written to file. " I dont understand what is the problem. Any one can help me? Thanks in advance!

채택된 답변

V K
V K 2016년 10월 29일
I would not recommend using "save" for saving variables as text files.
For starters, try csvwrite or dlmwrite. For example, to write-out the variable "result" to a comma separated text file, use csvwrite('test_output.csv',result)
If you instead want to try writing strings and numbers together, look up "fprintf".
Good luck!
  댓글 수: 1
Nora Hora
Nora Hora 2016년 10월 29일
Thank you!
One more question. Could you please help me how to make this with all my files using a loop if their name is like '000000.bin'. They are a sequence, but any code i tried failed because of the filename.
The name of the results should carry the name of the file, like '000000.txt'. Thanks in advance!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by