Borrar filtros
Borrar filtros

Saving output results in a for loop

12 visualizaciones (últimos 30 días)
Macarena Santillan
Macarena Santillan el 13 de Jul. de 2021
Comentada: Macarena Santillan el 14 de Jul. de 2021
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

Respuesta aceptada

KSSV
KSSV el 14 de Jul. de 2021
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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by