Help with "if" function.

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

回答 (1 件)

per isakson
per isakson 2013 年 9 月 20 日

1 投票

Try
if e>=2 && e<=4

この質問は閉じられています。

質問済み:

2013 年 9 月 20 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by