Two functions on Same Graph - Vector Error

1 vue (au cours des 30 derniers jours)
jack carter
jack carter le 15 Avr 2017
Modifié(e) : dpb le 17 Avr 2017
I am trying to plot the attached curve (dashed line of the Model) in Matlab, but I am getting error in my coding.
The attached plot is a combination of two equations (shown in the attached image) with different limits. I have marked the respective parts of both equations with red.
I tried to use two different methods but I am getting errors.
Method#1: %The value of S0 is 14.6 (This value I have taken from another equation, which I have not shown in the image)
E=60000; d=0.014; n=4500; G=6.0; Le=0.46; B=0.05; r=3.0; S0=14.6;
%For equation#1,
S = 0:0.01:S0;
P1 = sqrt(((pi^2*r*E*d^3*(1+n)*S)/2)+((pi^2*G*E*d^3)/2));
plot(S, P1);
%For equation#2,
S = S0:0.1:Le;
P2=pi*d*r*(1+B*(S-S0)/d)*(Le-S+S0);
hold on;
plot(S, P2);
hold off
%%%%I am getting the following error, with above codings.
Error using *
Inner matrix dimensions must agree.
Error in myeqsetlin (line 117)
P2=pi*d*r*(1+B*(S-S0)/d)*(Le-S+S0);
%%%%Method Two
S=0:0.01:Snot;
f = @(S) sqrt(((pi^2*r*E*d^3*(1+n)*S)/2)+((pi^2*G*E*d^3)/2));
f = @(S) pi*d*r*(1+B*(S-S0)/df)*(Le-S+S0);
ezplot(f, [0.0 1.0])
S=S0:0.01:Le;
f2 = @ (S) pi*d*r*(1+(B*(S-S0))/(d))*(Le-S+S0);
ezplot(f2, [0.0 1.0])
%%%%By the second method i can only get one plot and the result is not matching the shown image at all.
I would be thankful if someone could help me on correcting both methods.

Réponses (1)

dpb
dpb le 15 Avr 2017
Modifié(e) : dpb le 16 Avr 2017
Several issues, the firstest is that you need the element-wise multiplication operator for P2, not matrix multiplication. These are the "dot" operators in Matlab...
P2=pi*d*r*(1+B*(S-S0)/d).*(Le-S+S0);
After that, with
Le=0.46;
S0=14.6;
then
S = S0:0.1:Le; --> S= 14.6: 0.1: 0.46;
which results in 0-length S since the end value is greater than the start.
There's something funky going on here w/ S as shown in your figure and how the equations are written it seems. It looks like the plot S is a normalized value 0:1 whereas you're trying to use some other length(?). Not sure how to grapple with that. If I simply use the figure normalized breakpoint that looks to correlate with your S0/100, I can get a plot of the shapes but the normalization is off...you'll have to figure out how that was actually done, precisely...
>> E=60000; d=0.014; n=4500; G=6.0; Le=0.46; B=0.05; r=3.0; S0=14.6;
>> S0=S0/100; % put back to scale of figure, roughly...
>> S=linspace(0,S0,20); % some points between origin and S0
>> P1 = sqrt(((pi^2*r*E*d^3*(1+n)*S)/2)+((pi^2*G*E*d^3)/2));
>> S2=linspace(S0,1,50); % points between S0 and 1
>> P2=pi*d*r*(1+B*(S2-S0)/d).*(Le-S2+S0);
>> hold all
>> plot(S2,P2*100+20) % arbitrary adjust P2 to get roughly same scaling...
results in
As noted, you'll need to figure out the actual scaling between the presented figure and the equations...there's some sleight-of-hand going on there it seems.
  2 commentaires
jack carter
jack carter le 17 Avr 2017
Thank you for your answer. The value of S in original reference is normalized, as you have mentioned. Can you kindly re-modify the code for normalized result?
The value of S0 (refers to the lowest point at which the curve drops to after the first peak) which is around less than 0.2 according to the given plot.
I would like to get the exact curve as shown in the image.
dpb
dpb le 17 Avr 2017
Modifié(e) : dpb le 17 Avr 2017
Well, you're lacking information to do that...parameters aren't all supplied that were used to generate the plot. You'll have to either find them somewhere else in the text/paper/wherever that came from or back-solve for them...certainly the E you've plugged in isn't close in the results.
The origin value is pi/sqrt(2)*d*sqrt(GEd) for S-->0 which the figure has at something approaching zero with the dashed line but the datapoints appear in the neighborhood of 100 at the origin.
With the other values above, setting E-->
>> E=1;
>> pi*(sqrt(G*E*d^3/2))
ans =
309.8155
>>
which is about 3X value needed. Since E is in the square root, to reduce the result by 3,
>> E=1/9;
>> pi*(sqrt(G*E*d^3/2))
ans =
103.2718
>>
There's a starting point that at least seems in the neighborhood but that E certainly resembles nothing like what you had above...

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by