What is wrong with this code?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Prithvi Shams
am 12 Okt. 2019
Beantwortet: Star Strider
am 12 Okt. 2019
I would like to plot the following function
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)
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Okt. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Bar Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!