필터 지우기
필터 지우기

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