continue and return in a loop
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dion Theunissen
am 3 Mär. 2021
Beantwortet: darova
am 3 Mär. 2021
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);
0 Kommentare
Akzeptierte Antwort
darova
am 3 Mär. 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Point Cloud Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!