How to Show 1/4 in 1/2^2?

조회 수: 6 (최근 30일)
Junyong Hu
Junyong Hu 2019년 2월 15일
댓글: Matt J 2019년 2월 15일
I want to show 1/x^2,x=1,2,3....10;in 1/2^2, 1/3^2, 1/4^2.... but 1/4,1/9,1/16. How to do so.

답변 (3개)

John D'Errico
John D'Errico 2019년 2월 15일
Do you mean this?
format rat
1./(1:10).^2
ans =
1 1/4 1/9 1/16 1/25 1/36 1/49 1/64 1/81 1/100
  댓글 수: 1
Junyong Hu
Junyong Hu 2019년 2월 15일
No, I want 1/4 1/9 show as 1/2^2 1/3^3

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


madhan ravi
madhan ravi 2019년 2월 15일
편집: madhan ravi 2019년 2월 15일
I can only think of printing it using fprintf():
fprintf('1/%d^2 ',x)
  댓글 수: 2
Junyong Hu
Junyong Hu 2019년 2월 15일
fprintf('1/%d^2 ',x.^2) shows 1/4 1/9 1/16 1/25 not 1/2^2 , 1/3^2, 1/4^2.what I need is the 1/x^2 one .
Matt J
Matt J 2019년 2월 15일
But
fprintf('1/%d^2 ',x.^2)
is not what was proposed, but rather
fprintf('1/%d^2 ',x)

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


Matt J
Matt J 2019년 2월 15일
편집: Matt J 2019년 2월 15일
You can also create symbolic numbers
sym(1/3)
1/3
but be mindful that all calculations you do with such numbers will also give symbolic results only.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by