How can we do for following fprintf formating

조회 수: 15 (최근 30일)
PULAK Kumer
PULAK Kumer 2020년 11월 27일
댓글: Francis Adesayo 2022년 11월 21일
How can i show power 2 of x in fprintf as general format?
  댓글 수: 3
PULAK Kumer
PULAK Kumer 2020년 11월 27일
How can we show this in fprintf
PULAK Kumer
PULAK Kumer 2020년 11월 27일
Please tell sir..I want to see 2 as a superscript of x using fprintf

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

채택된 답변

Star Strider
Star Strider 2020년 11월 27일
Try this:
fprintf('\tx%c\n', char(178))
producinig:
x²
.
  댓글 수: 2
PULAK Kumer
PULAK Kumer 2020년 11월 27일
Thank you sir
Star Strider
Star Strider 2020년 11월 27일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (2개)

Francis Adesayo
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
Star Strider 2022년 11월 21일
Proof of concept —
ssc = [185 178 179];
fprintf('\tx%c\n', char(ssc))
x¹ x² x³
Vectorised!
.
Francis Adesayo
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
Ameer Hamza 2020년 11월 27일

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by