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

2 次查看(过去 30 天)
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 个评论
Ahmad Abbas
Ahmad Abbas 2020-12-14
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 2020-12-14
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,[]);

请先登录,再进行评论。

采纳的回答

Ive J
Ive J 2020-12-14
编辑:Ive J 2020-12-14
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by