exit from loop

hi, in the following code,I need when mat(k,2)=map(j,2)exit of loop.
for j=1:i
for k=1:L
if map(j,1)==mat(k,2)
mat(k,2)=map(j,2);
end
end
end

Antworten (1)

Walter Roberson
Walter Roberson am 12 Okt. 2011

0 Stimmen

leave_early = false;
for j=1:i
if leave_early; break; end
for k=1:L
if map(j,1)==mat(k,2)
mat(k,2)=map(j,2);
leave_early = true;
break
end
end
end

2 Kommentare

Andrei Bobrov
Andrei Bobrov am 12 Okt. 2011
[i1,j1] = find(bsxfun(@eq,map(:,1)',mat(:,2)),1,'first');
mat(i1,2)=map(j1,2);
Jan
Jan am 12 Okt. 2011
@Andrei: Please post this as an answer.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 12 Okt. 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by