sprintf conflict in operations

3 ビュー (過去 30 日間)
Opariuc Andrei
Opariuc Andrei 2021 年 3 月 24 日
コメント済み: Star Strider 2021 年 3 月 24 日
receiving 5 values for Mt2b while using sprintf for Pmax (i used to to get an exact value without variables) .if i remove sprintf from Pmax i'm receiving 1 value as needed .The question being how can fix my result for Mt2b without having to remove sprintf from Pmax ?
Fa=88050;
E=2.1*10^5;
R=200;
r0=1.11*((Fa*R)/E)^(1/3)
Pmax=sprintf('%.0f\n',0.39*((Fa*E^2)/R^2)^(1/3))
Mt2b=sprintf('%.0f\n',((pi^2)/8)*0.2*Pmax*r0^3)

採用された回答

Star Strider
Star Strider 2021 年 3 月 24 日
To use ‘Pmax’ in a calculation, it has to be turned back into a number.
Try this:
Mt2b=sprintf('%.0f\n',((pi^2)/8)*0.2*str2double(Pmax)*r0^3)
producing:
Mt2b =
'50709
'
.
  2 件のコメント
Opariuc Andrei
Opariuc Andrei 2021 年 3 月 24 日
thx ,i'll write that down somewhere , for future reference :)
Star Strider
Star Strider 2021 年 3 月 24 日
As always, my pleasure!
The online documentation reference is str2double

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by