필터 지우기
필터 지우기

How to Save multiple files from a loop with separate names

조회 수: 6 (최근 30일)
MILLER BIGGELAAR
MILLER BIGGELAAR 2020년 4월 2일
댓글: MILLER BIGGELAAR 2020년 4월 2일
Hi guys,
Essentially I am running a loop which allows the user to select as many files as necessary, filter them and plot them agasint each other in one graph. The last task is to save the filtered data into a folder which I have created however I don't know how to do this. I think that the save command must have to exist within the loop but I want it to be able to save the filtered data as the original file name with 'Filtered_' as a prefix to it as well as saving it in a separate folder, any clue on what to do?
here is the program
for i = 1:length(list)
Data = load(list{i});
E = Data(:,1);
N = Data(:,2);
D = Data(:,3);
Eb = find(E>Filt_Elow);
UserE = E(Eb);
UserN = N(Eb);
UserD = D(Eb);
E = UserE;
N = UserN;
D = UserD;
Nb = find(N>Filt_Nlow);
UserE_1 = UserE;
UserN_1 = UserN;
UserD_1 = UserD;
UserE_1 = UserE(Nb);
UserN_1 = UserN(Nb);
UserD_1 = UserD(Nb);
figure(1)
plot3(UserE_1, UserN_1 ,UserD_1, '.')
hold on
end
% i was attempting to use Filename = list(i,:)
% and then save('Filtered_Data/Filtered_'(Filename))
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2020년 4월 2일
Before the loop
outdir = 'Filtered_Data';
outprefix = 'Filtered_';
Inside the loop:
outfile = fullfile( outdir, [outprefix list{i}]);
save(outfile, 'UserE_1', 'UserN_1', 'UserD_1'); %change to appropriate list of variable names

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by