continue and return in a loop

조회 수: 3 (최근 30일)
Dion Theunissen
Dion Theunissen 2021년 3월 3일
답변: darova 2021년 3월 3일
Hi,
See my script below. I added in this script what I exactly want.
So if a value is what i want it is, go out of the loop and continue the script.
How can I fix this?
fullfilename = fullfile(RCA(30).folder, RCA(30).name);
for k = 1:length(RCA)
fullfilename = fullfile(RCA(k).folder, RCA(k).name);
thisData = readmatrix(fullfilename, 'Range', 2, 'Delimiter', ',');
%% Run ICP (standard settings)
for i = 2:100
[Ricp Ticp ER weight] = icp(M, D, i);
% Transform data-matrix using ICP result
Dicp = Ricp * D + repmat(Ticp, 1, n);
set(0, 'CurrentFigure', f1)
ER1 = ER(end-1) - ER(end)
end
%% this is the point where i need to add something:
%% If ER1 < 0.005 it has to continue outside the i loop.
%% So if ER < 0.005 continue at plot3(D..... otherwise continue for i = 3 and so on.
plot3(D(1,:),D(2,:),D(3,:),'bo',M(1,:),M(2,:),M(3,:),'-');
hold on
xlim([-40 70]);
ylim([-50 50]);
zlim([-90 10]);
ER2(k,1)=ER(end);
ER2(k,2) = ER(end-1)-ER(end);

채택된 답변

darova
darova 2021년 3월 3일
Here is the solution
for i = 2:100
[Ricp Ticp ER weight] = icp(M, D, i);
% Transform data-matrix using ICP result
Dicp = Ricp * D + repmat(Ticp, 1, n);
set(0, 'CurrentFigure', f1)
ER1 = ER(end-1) - ER(end)
if ER1 < 0.005
break
end
end
%% this is the point where i need to add something:
%% If ER1 < 0.005 it has to continue outside the i loop.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by