Quantcast
Channel: MATLAB Central Newsreader - tag:"variables"
Viewing all articles
Browse latest Browse all 41

How to ask MATLAB if a variable is equal to three different values?

$
0
0
I'm trying to ask matlab if the (4,3) value of matrix G is equal to 5, 2 or 1.

The matrix value of G(4,3)==2, but when I input (G(4,3)==(2||1||5)) it says the ans =0
How do I ask if the variable value is one of three values?

I tried putting in G(4,3)==(4||5) and the answer was 0 (so untrue) but then I took away the brackets, G(4,3)==4||5 and the answer was 1(true)

So I tried putting in G(4,3)==16||65 (these values don't even exist in my matrix, and it came out with the answer 1, true?! I don't know why though.

Viewing all articles
Browse latest Browse all 41

Trending Articles