If statement with OR operator to create error message for a function
1 view (last 30 days)
Show older comments
Hi
I have a function that has a second input that must be 8, 12 or 16. I want to have an error message to flag when the 2nd input does not take these values. I have tried doing this in an if statement:
if A~=8 || A~=12 || A~=16
error('..','...')
end
Of course, I think my logic here is wrong (if the input is 12, it is true for the A~=8 or 16) and so the if statement is always true and can never be false. Would an AND/OR work (if these exist in matlab)?
Is there a way I can do this in an if statement? Or is there a better way of writing what I'm trying to do?
Thanks for your help!
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Signal Generation and Preprocessing 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!