What is wrong with this code?
1 view (last 30 days)
Show older comments
Prithvi Shams
on 12 Oct 2019
Answered: Star Strider
on 12 Oct 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 Comments
Accepted Answer
Star Strider
on 12 Oct 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 Comments
More Answers (0)
See Also
Categories
Find more on Bar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!