Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

If statement

Asked by James on 10 Aug 2011
for a = [10,110,210]
for b = [1,2,3,4,5,6,7,8,9,10]

c = a + b

end
end

Below these two loops i want to do different processes if b any of these values (1,2,5,6,8) else I will do a different process.

I was thinking an if statement but i dont know how to do this. Please help!

0 Comments

James

Tags

Products

No products are associated with this question.

1 Answer

Answer by Friedrich on 10 Aug 2011

Hi,

you can use

if ismember(b,[1,2,5,6,8])
 %b equals one of the number
else
 %do something else
end

0 Comments

Friedrich

Contact us