필터 지우기
필터 지우기

using cat for a sequence of files

조회 수: 1 (최근 30일)
antonet
antonet 2012년 5월 29일
suppose that I have some excel files(more than 2, actually 12). How can i use the command ' cat ' in a loop? I want to place one excel file below the other
I am looking something like:
clear all;
fname = {'dataoutput1.xlsx','dataoutput2.xlsx','dataoutput3.xlsx','dataoutput4.xlsx'};
for i=1:length(fname)
a = xlsread(fname{i})
lo=cat(length(fname), a(i,:))
end
Does it matter if the files have different dimensions?
thank

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 5월 29일
about function cat
fname = {'dataoutput1.xlsx','dataoutput2.xlsx','dataoutput3.xlsx','dataoutput4.xlsx'};
a = cellfun(@xlsread,fname,'un',0);
[m,n] = cellfun(@size,a);
mm = max(m);
mn = max(n);
out1 = arrayfun(@(x,y,z)[x{:},nan(y,mn-z)],a,m,n,'un',0);
out1 = cat(1,out1{:});
out2 = arrayfun(@(x,y,z)[x{:};nan(mm-y,z)],a,m,n,'un',0);
out2 = cat(2,out2{:});
  댓글 수: 3
Oleg Komarov
Oleg Komarov 2012년 5월 29일
[data,text,all] = xlsread()
Check out the third output of xlsread.
antonet
antonet 2012년 5월 30일
thank you oleg

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by