How to code multiple "if" conditions in app designer?

I'm making a calculator app, that uses lots of variables, and one of these variables has a lot of conditions, so i'm trying to make something like
if tsd<=fyd
Sigma_sd=Es*epsilon_s;
elseif tsd>fyd&&Fck<=35&&Delta<=0.17&&fyk=50
Sigma_sd=43.48;
elseif tsd>fyd&Fck>35&&Delta<=0.17&&fyk=50
Sigma_sd=47.5;
elseif tsd>fyd&Fck<=35&&Delta<=0.17&&fyk=60
Sigma_sd=50
elseif tsd>fyd&Fck>35&&Delta<=0.17&&fyk=60
Sigma_sd=51
end
i also want to add more conditions to this code, for when Delta is higher then 0.17, and for delta higher than 0.20, so i think it would be something like this
elseif tsd>fyd&Fck>35&&0.17<delta<=0.2&&fyk=60
Sigma_sd=51;
elseif tsd>fyd&Fck>35&&Delta>0.20&&fyk=60
Sigma_sd=51;
i'm not asking for anyone to make my code, but just to help me to make a coded mult conditions such as my example above.
thanks for any help.

Answers (1)

if a < b < c
does not work.
You have to split the condition in two:
if a < b & b < c
And
if a = b
does not work.
A logical comparison for equality would be
if a == b
But checking for equality usually does not work because of floating-point arithmetic.

1 Comment

good to know that! i will use it in my codes for sure.
also, my biggest doubt wasn't answered.
maybe i can ask more clearly: i need to check if one varible is higher than the other, and if it is, i can use it's value to another equation, if not, i have to check on a table for it's value. I know how to check if it is higher or not, but i need to put the table numbers inside my code, and the table has a lots of conditions. Before you think i want a table in my app, that's not it. I need to make the app to check the table for the number, but since the app doesn't work like this, i need to write a code line to fullfill the table requirements.

Sign in to comment.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products

Release

R2023a

Asked:

on 20 May 2023

Commented:

on 20 May 2023

Community Treasure Hunt

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

Start Hunting!