exit from a nested while loop after having set its index to a given value
古いコメントを表示
I would like to exit from a nested while loop with return but before I would like to set my index to a given value as it follows:
function [H12] = samehorizon(F1,F2)
%UNTITLED Summary of this function goes here
% Il counter non si azzera mai e non riesco a incrementare l'indice i
alltime= [F1{:,1};F2{:,1}];
t1= min(alltime);
t2= max (alltime);
thor= t1: seconds(1):t2;
thor=thor';
thor=array2table(thor);
A= zeros(height(thor), 7);
H12= array2table(A);
H12.A1 = NaT(height(thor),1,'Format', 'dd-MMM-yyyy HH:mm:ss.SSSSSSSSS' );
prova=1;
for i=1:height(thor)
j=prova;
counter2=0;
Xtot2=0;
Ytot2=0;
H12(i,1)= thor(i,1);
H12(i,5)= F2(1,2);
while j <=height(F2)
if j== height(F2)
break
end
if (thor{i,1} - F2{j,1}) > duration('00:00:02.000000000')
prova=j-3;
break
end
if thor{i,1} - F2{j,1} <= duration('00:00:01.000000000')
Xtot2= Xtot2 + F2{j,3};
Ytot2= Ytot2 + F2{j,4};
counter2= counter2+1;
Xmean2 = (Xtot2/counter2);
Ymean2= (Ytot2/counter2);
H12{i,6}= Xmean2;
H12{i,7}= Ymean2;
end
j=j+1;
end
end
end
The error is: Index in position 1 is invalid. Array indices must be positive integers or logical values. referred to this line. In fact, prova always is equal to one...
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!