continue and return in a loop

2 ビュー (過去 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 Center および File ExchangePoint Cloud Processing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by