Effacer les filtres
Effacer les filtres

How to Save multiple files from a loop with separate names

6 vues (au cours des 30 derniers jours)
MILLER BIGGELAAR
MILLER BIGGELAAR le 2 Avr 2020
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

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Avr 2020
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

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by