How can I save the result obtained from the For loop in one variable ?

2 ビュー (過去 30 日間)
수연 박
수연 박 2022 年 1 月 11 日
コメント済み: Stephen23 2022 年 1 月 11 日
I used a for loop to calculate the radius for each picture of the circle in the folder.
However, not all data are accumulated in the radius variable, only the radius value for the final i value is obtained.
I want to save the circle radius values of all photos to an excel file.
Any help would be appreciated.

採用された回答

Simon Chan
Simon Chan 2022 年 1 月 11 日
You may assign another variable with index which stores the result within the loop
for i = 1:10
%....
%....
[centers, radii] = imfindcircles(A,[15 30]);
centers_combine{i} = centers;
radii_combine{i} = radii;
%....
end
  1 件のコメント
Stephen23
Stephen23 2022 年 1 月 11 日
More robust with preallocation:
N = 10;
centers_combine = cell(1,N);
radii_combine = cell(1,N);
for k = 1:N
%....
%....
[centers, radii] = imfindcircles(A,[15 30]);
centers_combine{k} = centers;
radii_combine{k} = radii;
%....
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by