How can we do for following fprintf formating
15 ビュー (過去 30 日間)
古いコメントを表示
How can i show power 2 of x in fprintf as general format?
3 件のコメント
採用された回答
Star Strider
2020 年 11 月 27 日
Try this:
fprintf('\tx%c\n', char(178))
producinig:
x²
.
2 件のコメント
Star Strider
2020 年 11 月 27 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
その他の回答 (2 件)
Francis Adesayo
2022 年 11 月 21 日
you can type x and then on your keyboard press and hold the alt key while you type 253 on the number pad on the right of the keyboard. This only works if your keyboard has the number pad.
You will get x².
Likewise, math symbols such as the integral symbol --> ∫ x² dx can be gotten by pressing the windows button and semicolon button. And then go to symbols tab, and then to math symbols and select the one you want. This way you dont have to type any special ascii code or use %c.
4 件のコメント
Star Strider
2022 年 11 月 21 日
Proof of concept —
ssc = [185 178 179];
fprintf('\tx%c\n', char(ssc))
Vectorised!
.
Francis Adesayo
2022 年 11 月 21 日
The OP just wanted x² printed on the command window. I simply provided an alternative way which has the added benefit of making the code look cleaner. Cheers Star Strider.
Ameer Hamza
2020 年 11 月 27 日
It is not possible to do such thing in command window currently: https://www.mathworks.com/matlabcentral/answers/255568-putting-a-subscript-into-a-string-displaying-the-command-window
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!