Info

This question is closed. Reopen it to edit or answer.

Help with "if" function.

3 views (last 30 days)
Arthur
Arthur on 20 Sep 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
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
per isakson on 20 Sep 2013
Try
if e>=2 && e<=4

Community Treasure Hunt

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

Start Hunting!