fprint problem in matlab
2 ビュー (過去 30 日間)
古いコメントを表示
why the outstr value is 24 here ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/308744/image.png)
0 件のコメント
回答 (1 件)
Star Strider
2020 年 6 月 2 日
The fprintf fuction returns the number of bytes ouitput to the file.
2 件のコメント
Star Strider
2020 年 6 月 2 日
In the code in your image of it (not the actual code, that I had to type in manually), the value is in ‘outstr’. It writes 24 bytes to the file, and the full string to your Command Window (the default output), returning 24 in ‘outstr’.
If you want it to return the actual string to your workspace, use:
outstr = sprintf('The answer is %s', data1);
That works. (I tested it.)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!