Changing input name to save data from zip files into a data cell?

I want to take information from a bunch of zip files and store the names of their contained files into a data cell. But I am not sure when using the "unzip()" function how I can do this.
I have multiple zip files that have the same name, except there is one number at the end of each file name that continually goes up. Is there any way to right a loop that will change the name of the input?? For example something like:
for i = 1:100
data(i,1) = unzip(filename(i));
end
in a way that this would be read as
filename1 filename2 filename3 . . . .
any help would be appreciated, and I can clarify more if you'd like.

Respuestas (1)

Stephen23
Stephen23 el 2 de Oct. de 2018
Editada: Stephen23 el 26 de Abr. de 2021
"Is there any way to right a loop that will change the name of the input??"
Of course, just follow the advice in the MATLAB documentation:
Note that if you want to use dir and want the files listed in alphanumeric order then you can download my FEX submission natsortfiles to do this:
P = 'directory where the files are';
S = dir(fullfile(P,'*.zip'));
S = natsortfiles(S); % download from FEX
for k = 1:numel(S)
S(k).data = unzip(fullfile(P,S(k).name));
end

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 2 de Oct. de 2018

Editada:

el 26 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by