How to select values of array using the logical operator "OR"?
7 views (last 30 days)
GOAL: Hi, I have an array A and want to build a new array B by selecting two or more values using the logical operator OR.
MY SOLUTION: I wrote the following lines:
A=[1 3 4 3 7 8 5 4 6 5]';
for i = 1:numel(A)
if A(i) == 3 || 5;
B(i) = A(i);
B(i) = NaN;
PROBLEM: The logical operator OR is not working. The array B is not correct because it is identical to array A. As a result I expected to see:
However, If I remove the logical operator OR, B is correct but does not include the value 5.
I wonder if someone could tell me what I'm doing wrong and how to correct these lines.
Thank you in advance for your attention