Help with "if" function.
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hello all,
I'm new to MatLab, wich I use in a computer class in my field of study. I'd like to know only a thing about the "if" function.
I want to write a programme that will calculate the value of a weight, and the error that is acceptable on the weight. Then, I want to use a if statement that will tell the user either if the weight is in the acceptable range or it isn't. Here's what I have in mind :
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
e=3
if e==[2,4] %I want the statement to be : if e is element of the following range
display('It''s ok')
elseif e==out of range
display('It''s not ok')
end
Answers (1)
per isakson
on 20 Sep 2013
1 vote
Try
if e>=2 && e<=4
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!