MATLAB Plot- URGENT. I am trying to plot for a variable incrementing 1:K for a s
ID: 3846526 • Letter: M
Question
MATLAB Plot- URGENT. I am trying to plot for a variable incrementing 1:K for a specified value K. The variable in question is P, which is to by my y-axis. The plot itself is an attempt at modeling a JKR/Hertzian contact mechanics curve for a given specimen I have used. I have written all the constants and provided the equations as they are in the MATLAB code I have written. There are several problems:
. The plot won't graph. It will open up the window and no curve or point is plotted.
. The workspace shows incorrect values for constants a0R1 and a0R2, including other constants. If you calculate them by hand using the variables I have provided, you will see what I mean.
. The values in the workspace seem to be overwriting each other so I don't know how to plot JKR_Total for a continuous stream of varying P, by increments of deltaP = 0.4e-8.
The code is attached as two pictures below:
Explanation / Answer
we can write e as exp(1) in MatLab
5e means vpa(5,exp(1))
Modified Code is:
pi = 3.141592;
R1 = vpa(12.66,exp(1))-6;
R2 = vpa(38,exp(1))-6;
E_Star = vpa(1.333,exp(1))*3;
R_Eff = vpa(9.496,exp(1))-6;
W_Adh = vpa(178,exp(1))-9;
DeltaP = vpa(0.4,exp(1))-8;
P = 0;
a0R1 = (((8*pi*W_Adh*E_Star)^(1/2))/((4*E_Star)/3*R1))^(2/3);
a0R2 = (((8*pi*W_Adh*E_Star)^(1/2))/((4*E_Star)/3*R2))^(2/3);
d1S = vpa(671,exp(1))-9;
d2S = vpa(1.397,exp(1))-6;
K = 300;
JKR_Total_Array = [];
P(1:K) = NaN;
a1R1(1:K) = NaN;
a1R2(1:K) = NaN;
d1H(1:K) = NaN;
d2H(1:K) = NaN;
for kk = 1:K
P(kk) = kk*DeltaP;
a1R1(kk) = ((3*R1)/(4*E_Star))*(P(kk)+(3*pi*W_Adh*R1) + ((6*pi*W_Adh*R1*P(kk))+(3*pi*W_Adh*R1)^2)^(1/2))^(1/3);
a1R2(kk) = ((3*R2)/(4*E_Star))*(P(kk)+(3*pi*W_Adh*R2) + ((6*pi*W_Adh*R2*P(kk))+(3*pi*W_Adh*R2)^2)^(1/2))^(1/3);
d1H(kk) = (((a1R1(kk))^2)/(R_Eff))-(((2*pi*W_Adh*a1R1(kk))/(E_Star))^(1/2));
d2H(kk) = (((a1R2(kk))^2)/(R_Eff))-(((2*pi*W_Adh*a1R2(kk))/(E_Star))^(1/2));
JKR_Total = ((d1H(kk) - d1S) + (d2H(kk) - d2S));
JKR_Total_Array = [JKR_Total, P];
end
plot(JKR_Total_Array,P(kk));
hold on
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.