How to Show 1/4 in 1/2^2?
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(3 个)
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
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 个评论
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!