MATLAB Answers

Code not working in APPDESIGNER...Only change is ifelse statement

1 view (last 30 days)
Aishwarya Vyas
Aishwarya Vyas on 28 Nov 2019
Edited: Aishwarya Vyas on 28 Nov 2019
R1=app.R1mmEditField.Value;
R2=app.R2mmEditField.Value;
L=app.LmmEditField.Value;
E1=app.ElasticModulusbody1Nmm2EditField.Value;
E2=app.ElasticModulusbody2Nmm2EditField.Value;
v1=app.PoissonsRatiobody1EditField.Value;
v2=app.PoissonsRatiobody2EditField.Value;
F=app.ForceEditField.Value;
if app.GEOMETRIESDropDown.Value=="CYLvsCYL"
% Defining geometrical parameters of Cylinder
%Calculating the contact half width
A=(4*F)/(3.14*L); Error using /Matrix dimensions must agree.
L1=(1/R1)+(1/R2);
Etot=(((1-v1^2)/E1)+((1-v2^2)/E2));
b=((A*Etot)/L1)^0.5;
%Calculating the pressure max
Pmax=2*F/(pi*b*L);
%Calculating the penetration depth;
app.PRESSUREMAXEditField.Value=Pmax;
app.EllipticalAxisEditField.Value=b;
elseif app.GEOMETRIESDropDown.Value=="SPHvsSPH"
%Calculating the contact half width
A=(3*F)/4;
Etot=(((1-v1^2)/E1)+((1-v2^2)/E2));
M=(1/R1)+(1/R2);
b=((A*Etot)/M)^(1/3);
%Calculating the pressure max
Pmax=(3*F)/(2*pi*b*b);
%Calculating the penetration depth;
%http://home.ufam.edu.br/berti/nanomateriais/8403_PDF_CH03.pdf
app.PRESSUREMAXEditField.Value=Pmax;
app.EllipticalAxisEditField.Value=b;
elseif app.GEOMETRIESDropDown.Value=="CYLvsPLATE"
%Calculating the contact half width
A=(4*F*R1)/(pi*L);
Etot=(((1-v1^2)/E1)+((1-v2^2)/E2));
b=(A*Etot)^0.5;
%Calculating the pressure max
Pmax=2*F/(pi*b*L);
%Calculating the penetration depth;
%http://home.ufam.edu.br/berti/nanomateriais/8403_PDF_CH03.pdf
%Below equation is valid only for steel..No equation is available
app.PRESSUREMAXEditField.Value=Pmax;
app.EllipticalAxisEditField.Value=b;
elseif app.GEOMETRIESDropDown.Value=="SPHvsPLATE"
%Calculating the contact half width
A=(3*F)/4;
Etot=(((1-v1^2)/E1)+((1-v2^2)/E2));
M=(1/R1)+(1/R2);
b=((A*Etot)/M)^(1/3);
%Calculating the pressure max
Pmax=(3*F)/(2*pi*b*b);
app.PRESSUREMAXEditField.Value=Pmax;
app.EllipticalAxisEditField.Value=b;
end
The error is as highlighted.
My question is why is a matrix variable formed .I can solve using ./ but it should be declared as a scalar right?

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.


Translated by