Command save writes to a nonreadable text file
2 次查看(过去 30 天)
显示 更早的评论
When I execute the below Script file
x = 2; y = x^5;
save result.txt y
and open result.txt in MATLAB, the text shown is not readable.
What tpye of encoding is this? I know that when I add -ascii the text becomes readable, but I'm curious to learn the type of encoding above and why is it the default text file.
0 个评论
回答(1 个)
Cris LaPierre
2021-11-1
The save command as written is creating a mat file. To create a text file, use the '-ascii' flag.
x = 2;
y = x^5
save result.txt y -ascii
1 个评论
Walter Roberson
2021-11-1
To expand slightly:
save() does not examine the file extension to figure out whether binary or text form is desired. save() always writes in binary unless you specifically ask for text.
另请参阅
类别
在 Help Center 和 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!