Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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 Kommentare
Ahmad Abbas
Ahmad Abbas am 14 Dez. 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 am 14 Dez. 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,[]);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ive J
Ive J am 14 Dez. 2020
Bearbeitet: Ive J am 14 Dez. 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

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by