フィルターのクリア

Save data from a for loop in the same file

4 ビュー (過去 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 Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by