フィルターのクリア

Saving output results in a for loop

12 ビュー (過去 30 日間)
Macarena Santillan
Macarena Santillan 2021 年 7 月 13 日
コメント済み: Macarena Santillan 2021 年 7 月 14 日
Hello, I am trying to make a loop that will iterate based on the previous value and I want to save the results from each iteration in a table/array. I created the empty array beforehand but when I execute the code it return the empty array with the values from the last iteration on the last row.
I am also not sure if the code is actually using the previous value in the way I set it up, but Its not giving errors, so I am assuming its fine(?
Thank you for any help you can provide
results=zeros(500,3);
for i=1000:100:1500
for j=150:50:1608
[y,x]=min (ds(j:j+100,i));
minpix(i)=j+x;
[y1,x1]=min (ds(minpix(i)-50:minpix(i)+50,i-1));
minpix(i-1)=minpix(i)+x1;
PixSh= minpix(i-1)-minpix(i);
ChangeVel=PixSh/90;
results(i,:)=[i ChangeVel PixSh];
end
end

採用された回答

KSSV
KSSV 2021 年 7 月 14 日
results=zeros([],3);
count = 0 ;
for i=1000:100:1500
for j=150:50:1608
[y,x]=min (ds(j:j+100,i));
minpix(i)=j+x;
[y1,x1]=min (ds(minpix(i)-50:minpix(i)+50,i-1));
minpix(i-1)=minpix(i)+x1;
PixSh= minpix(i-1)-minpix(i);
ChangeVel=PixSh/90;
count = count+1 ;
results(count,:)=[i ChangeVel PixSh];
end
end
  1 件のコメント
Macarena Santillan
Macarena Santillan 2021 年 7 月 14 日
Thank you !! it works perfect (:

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by