How can the output be written in a new column (without overwriting the previous one)

조회 수: 1 (최근 30일)
Shel
Shel 2019년 2월 11일
댓글: M 2019년 2월 12일
I am processing several images and use loop for the series. I need to write the output of each loop in a new line beside the previous column.
for example: for the first loop I want data in column 2, for the second loop I want data in column 3 beside column 2
would you help me please?

답변 (1개)

M
M 2019년 2월 11일
편집: M 2019년 2월 11일
You can use cell for that. You can try and adapt the following example:
a=cell(3,1);
for i=1:3
a{i}=ones(i,1);
end
a =
3×1 cell array
{[ 1]}
{2×1 double}
{3×1 double}
  댓글 수: 7
Shel
Shel 2019년 2월 11일
here is my code of the loop:
for thresh=240:300
fprintf(file1, '%10s %2.5f \r\n', 'Threshold', thresh);
for i=1:totalfile
fname=['8--7-',num2str(i), '.dcm'];
indicom=dicomread(fullfile(source_dir, fname));
T=thresh;
indicom(find(indicom<T))=0;
img_NB=length(indicom(indicom==0));
fprintf(file1,' %2.0f %10s %2.5f \r\n', i, ' ', img_NB);
end
end
fclose(file1);
M
M 2019년 2월 12일
the output file should be filled out horizontally and it is not possible to do it vertically
You can do it both ways, you have to adapt the indexing.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by