How to Create a list and save it in a txt file?
조회 수: 4 (최근 30일)
이전 댓글 표시
I am reading data from files in a directory. I am taking the standard deviation of this data. Using an If loop I only plot the Values which are over a certain limit. For Example:
for i=1:(number of files)
x=load(file(i).mat) <---- this isn't how I load it in just example
xx=i;
y=std(x);
if y>0.5
plot(xx,y)
hold on
(Now I want to save the file names which fall in this condition to a .txt file and in the end have a list of each file)
end
end
hold off
figure;
What code can I use to fill the gap in the If loop to save these file names to a list?
댓글 수: 0
채택된 답변
ES
2017년 3월 10일
편집: Stephen23
2017년 3월 10일
%Open a log file for writing
fID= fopen(logfilename,'w');
..your code...
% Write filename into logfile
fprintf(fID,'%s\r\n',file(i).mat);
%Close logfile
fclose(fID)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!