Borrar filtros
Borrar filtros

How to Save multiple files from a loop with separate names

6 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by