Borrar filtros
Borrar filtros

mutiple reshaping files and the output have similar name of the input files

2 visualizaciones (últimos 30 días)
i am loading more than 60 ASCII files. i want to reshape them but i want the output files from the reashing match the input files names or at least the number name in the files.
files name fv895,fv898,fv995...............
clear
files = dir('fv*.asc');
for i=1:length(files)
eval(['load ' files(i).name ' -ascii']);
sd=reshape(files(i).name,1,[]);
end
  3 comentarios
Ahmad Abbas
Ahmad Abbas el 14 de Dic. de 2020
the eval was a mistake which i should not used it. i was trying to load all files then reshape them to do more anaylsing work.
Ahmad Abbas
Ahmad Abbas el 14 de Dic. de 2020
i am updating the code. i do not want to create many lines to reshape all the files. how i can create a loop to do it for me
%%
clear
files = dir('fv*.asc');
numfiles = length(files);
mydata = cell(1, numfiles);
for i=1:numfiles
load(files(i).name);
end
rfv1095=reshape (fv1095,1,[]);
rfv1098=reshape (fv1098,1,[]);
rfv1195=reshape (fv1195,1,[]);
rfv1195=reshape (fv1198,1,[]);
rfv1295=reshape (fv1295,1,[]);
rfv1295=reshape (fv1298,1,[]);
rfv1395=reshape (fv1395,1,[]);
rfv1395=reshape (fv1398,1,[]);
rfv1495=reshape (fv1495,1,[]);
rfv1495=reshape (fv1498,1,[]);
rfv1595=reshape (fv1595,1,[]);
rfv1595=reshape (fv1598,1,[]);
rfv1695=reshape (fv1695,1,[]);
rfv1695=reshape (fv1698,1,[]);
rfv1795=reshape (fv1795,1,[]);
rfv1795=reshape (fv1798,1,[]);
rfv1895=reshape (fv1895,1,[]);
rfv1895=reshape (fv1898,1,[]);
rfv1995=reshape (fv1995,1,[]);
rfv1995=reshape (fv1998,1,[]);

Iniciar sesión para comentar.

Respuesta aceptada

Ive J
Ive J el 14 de Dic. de 2020
Editada: Ive J el 14 de Dic. de 2020
I'm not aware of you file contents (or even whehter you can use load to read them). Regardless, you may need something like:
files = dir('fv*.asc');
mydata = cell(numel(files), 1);
for i = 1:numel(files)
mydata{i} = load(files(i).name); % still don't know if you need readtable, readcell, fread, etc instead of load
mydata{i} = reshape(mydata{i}, 1, []);
end

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by