MATLAB Answers

How to iterate through rows of a table, such that after each iteration some computation is done and then the below row is reached?

110 ビュー (過去 30 日間)
Raka Mukherjee
Raka Mukherjee 2020 年 1 月 8 日
コメント済み: Walter Roberson 2020 年 2 月 4 日
I have this piece of code
for ite=1:areasize
row= r(ite,:);
xmin=xCent(1,row) - size_of_cropped_img/2;
ymin=yCent(1,row) - size_of_cropped_img/2;
crop= imcrop(image,[xmin ymin size_of_cropped_img size_of_cropped_img]);
there are 15 rows which needs to be iterated one by one to get the cropped outputs.Until now only the first output has been extracted.
I would be greatly thankful if someone can assist.
  5 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 4 日
I see that you edited your code and removed most of the statements that people were commenting on.
However in your modified code, you are still overwriting all of the variable "crop" each time through the loop.


回答 (1 件)

Andrew Janke
Andrew Janke 2020 年 1 月 31 日
To iterate over the rows of a table, use height() to see how high your index should go:
for iRow = 1:height(r)
% ... do work on r(iRow,:) ...

Community Treasure Hunt

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

Start Hunting!

Translated by