# Thread: Question in matlab

1. ## Question in matlab

Hi All
I want to ask question in matlab, Can I create if loop inside for loop such that if on condition of if hold then for loop must end, i.e How can we do the following
For i = 1:2:10
if mod(i,2)=0
end
else
i
end

Best wishes

2. Originally Posted by raed
Hi All
I want to ask question in matlab, Can I create if loop inside for loop such that if on condition of if hold then for loop must end, i.e How can we do the following
For i = 1:2:10
if mod(i,2)=0
end
else
i
end

Best wishes
The correct program should read:

Code:
for i=1:2:10
if mod(i,2)==0
break
else
i
end
end

3. This has already been aswered in your last thread:

>>help break

CB