What is wrong with this code?

1 view (last 30 days)
Prithvi Shams
Prithvi Shams on 12 Oct 2019
Answered: Star Strider on 12 Oct 2019
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)

Accepted Answer

Star Strider
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.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!