How to clean up If-Statement
Show older comments
Can someone help me clean this up, I am sure there is a faster more effiecent way to define value units. Here is my code
u=symunit;
Modulus_Dim=input('\nWhat is the Units for your modulus inputs (0-PSI,1-GPa, 2-MPa, 3-Pa) *Must be consistent* :');
if (Modulus_Dim==0)%Running through an if statement to get units
if true
% code
end
Er=input('\nWhat is Er :')*u.psi;
Em=input('\nWhat is Em :')*u.psi;
Gr=input('\nWhat is Gr :')*u.psi;
Gm=input('\nWhat is Gm :')*u.psi;
else if (Modulus_Dim==1)
Er=input('\nWhat is Er :')*u.GPa;
Em=input('\nWhat is Em :')*u.GPa;
Gr=input('\nWhat is Gr :')*u.GPa;
Gm=input('\nWhat is Gm :')*u.GPa;
else if (Modulus_Dim==2)
Er=input('\nWhat is Er :')*u.MPa;
Em=input('\nWhat is Em :')*u.MPa;
Gr=input('\nWhat is Gr :')*u.MPa;
Gm=input('\nWhat is Gm :')*u.MPa;
else
Er=input('\nWhat is Er :')*u.Pascal;
Em=input('\nWhat is Em :')*u.Pascal;
Gr=input('\nWhat is Gr :')*u.Pascal;
Gm=input('\nWhat is Gm :')*u.Pascal;
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Entering Commands 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!