What is wrong with this code?

1 回表示 (過去 30 日間)
Prithvi Shams
Prithvi Shams 2019 年 10 月 12 日
回答済み: Star Strider 2019 年 10 月 12 日
I would like to plot the following function
2.png
where,
Ao = 0.2, E = 181e9, Beta = 200, Vo = 0.5 and Va = 0.85. The objective is to plot P1 for Vf = 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85
I plotted the graph in MATLAB using the code below, but the graph didn't make sense theory - wise. So I re-did the graph in Excel and it came out fine. I am wondering what I did wrong in my code!
It's obvious from the equation that for Vf = 0.5, the function should return 0. But I am getting a large value like 1.12e6!
Vf = (0.5:0.05:0.85);
P = - ( (0.2*0.5)./Vf).*( (1 - sqrt(Vf/0.5))/( (16/pi^3)*(200^2/181e9).*sqrt(0.85./Vf).*(sqrt(0.85./Vf)-1).^2 ) );
plot(Vf,P)

採用された回答

Star Strider
Star Strider 2019 年 10 月 12 日
You forgot to use element-wise division ...
P = - ( (0.2*0.5)./Vf).*( (1 - sqrt(Vf/0.5))./( (16/pi^3)*(200^2/181e9).*sqrt(0.85./Vf).*(sqrt(0.85./Vf)-1).^2 );
HERE
That worked when I ran it.

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by