saving all data from for loop after image processing

1 回表示 (過去 30 日間)
Babu Sankhi
Babu Sankhi 2020 年 10 月 19 日
コメント済み: Babu Sankhi 2020 年 10 月 19 日
Hi all,
I want to save my all data obtained from for loop in text file after each image processing. But it only saves last values . Can you please help me in this regard? How can I do that?
thank you
pngfiles=dir('*.png');
leftedge=[];
rightedge=[];
for i=1:2
folder = pwd;% current folder
File = pngfiles(i).name;
FiE = fullfile(folder, File);
% HERE IS MY IMAGE PROCESSING CODE FOR EACH IMAGE
distances = sqrt((x - xRight).^2 + (y - yRight).^2);
distances1 = sqrt((x - xleft).^2 + (y - yleft).^2);
[rightdistance, rightinnerIndex] = min(distances);
[leftdistance, leftinnerIndex] = min(distances1);
leftd=leftdistance
rightd=rightdistance
leftedgPMA63=[leftedge;(leftd)]; % gives the expansion distances in one column
rightedgPMA63=[rightedge;(rightd)];
% leftedgPMA6=[leftedge i]; I tried this way as well it did nt work???
% rightedgPMA6=[rightedge i];
c=[leftedgPMA63,rightedgPMA63];
dlmwrite('c.txt',c)
end
%%
%
% I tried putting
leftdistance,i
% but still it didnt work

採用された回答

Rik
Rik 2020 年 10 月 19 日
You should use the '-append' option if you don't want to overwrite your text file every iteration.
  3 件のコメント
Rik
Rik 2020 年 10 月 19 日
dlmwrite('c.txt',c,'-append')
What error does that return?
Babu Sankhi
Babu Sankhi 2020 年 10 月 19 日
thanks it works now

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by