Save data from a for loop in the same file

조회 수: 10 (최근 30일)
Albert
Albert 2014년 5월 21일
댓글: Albert 2014년 5월 21일
In the following code, with a for loop , I want to save all the values of T in the same file, actually it save each value in a different file. T is inside a for loop. I want the values in the same file to process it, thanks!
clear all; close all;
im_geo=imread('background.jpg');
figure; imshow(im_geo), title('background'); % Background
hold on
im_geoo=imread('signal imatge ac 15052014.jpg');
figure; imshow(im_geoo), title('bright line'); % Bright line
z=1;
x= linspace(0, 35, 35);
%totes les línies de la imatge
for p=170:1:350;
z=z+1; %eix x
%valors I
t=im_geoo(p:p,271:306);
u=im_geo(p:p,271:306);
tu=t-u;
%fwhm
mi= min(tu); ma= max(tu);
x_above= x(tu> (ma- mi)/ 2);
fwhm= x_above(end)- x_above(1);
%paràmetres
a=atan(69./(2.*570));
mmpx=5./102;
m=fwhm.*mmpx;
T=(sqrt(2).*a.*m)./(3e11);
name = num2str(p) ;
filename = mat2str([name '.txt']);
save(filename, 'T', '-ascii','-double','-append');
%plot (z,T)
%hold on
end

채택된 답변

Mahdi
Mahdi 2014년 5월 21일
I know there is a way to do it, but my brain is failing me at the moment. What you can do instead is hold all the T values in a matrix and then save that matrix:
i=1
for p=170:1:350
...
T(i)=(sqrt(2).*a.*m)./(3e11);
...
i=i+1;
end
filename="Put a filename here";
save(filename, 'T', '-ascii','-double','-append');
  댓글 수: 1
Albert
Albert 2014년 5월 21일
yeah, I'm new in matlab and i don't know a lot of things yet. Thank you a lot.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by