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

more for loop help

Asked by James on 7 Aug 2011
for c = 11:20
    if c~=11 && c~=14 && c~=17 && c~=20
        break
    end
% how can I loop through for all values of r, which are r=11,14,17,20????
end 

0 Comments

James

Products

No products are associated with this question.

2 Answers

Answer by proecsm on 7 Aug 2011
for k = 11:3:20
%do stuff
end

0 Comments

proecsm
Answer by Walter Roberson on 7 Aug 2011

Or you could use

for k = [11,14,17,20]
%do stuff
end

0 Comments

Walter Roberson

Contact us