Importing Data from Excel
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone, I have 32 Excel files and want to Combine the second column of all These files. I have written a code, but ist so disappointing. could you suggest me decent way? Thank you in advance!
m1=xlsread('1.xlsx','B2:B18183'); m2=xlsread('2.xlsx','B2:B18183'); m3=xlsread('3.xlsx','B2:B18183'); m4=xlsread('4.xlsx','B2:B18183'); m5=xlsread('5.xlsx','B2:B18183'); m6=xlsread('6.xlsx','B2:B18183'); m7=xlsread('7.xlsx','B2:B18183'); m8=xlsread('8.xlsx','B2:B18183'); m9=xlsread('9.xlsx','B2:B18183'); m10=xlsread('10.xlsx','B2:B18183'); m11=xlsread('11.xlsx','B2:B18183'); m12=xlsread('12.xlsx','B2:B18183'); m13=xlsread('13.xlsx','B2:B18183'); m14=xlsread('14.xlsx','B2:B18183'); m15=xlsread('15.xlsx','B2:B18183'); m16=xlsread('16.xlsx','B2:B18183'); m17=xlsread('17.xlsx','B2:B18183'); m18=xlsread('18.xlsx','B2:B18183'); m19=xlsread('19.xlsx','B2:B18183'); m20=xlsread('20.xlsx','B2:B18183'); m21=xlsread('21.xlsx','B2:B18183'); m22=xlsread('22.xlsx','B2:B18183'); m23=xlsread('23.xlsx','B2:B18183'); m24=xlsread('24.xlsx','B2:B18183'); m25=xlsread('25.xlsx','B2:B18183'); m26=xlsread('26.xlsx','B2:B18183'); m27=xlsread('27.xlsx','B2:B18183'); m28=xlsread('28.xlsx','B2:B18183'); m29=xlsread('29.xlsx','B2:B18183'); m30=xlsread('30.xlsx','B2:B18183'); m31=xlsread('31.xlsx','B2:B18183'); m32=xlsread('32.xlsx','B2:B18183'); recon=[ m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19 m20 m21 m22 m23 m24 m25 m26 m27 m28 m29 m30 m31 m32];
0 Commenti
Risposta accettata
dpb
il 13 Feb 2017
d=dir('*.xlsx'); % return directory list of all Excel files
x=[];
for i=1:length(d)
x=[x;xlsread(d(i).name,'B:B');
end
3 Commenti
dpb
il 14 Feb 2017
Modificato: dpb
il 14 Feb 2017
Then just remove the semicolon in the concatenation construct to do a horzcat instead of vertcat--
x=[x xlsread(d(i).name,'B:B');
Or, reshape the column vector above after the fact--
x=reshape(x,length(x)/length(d),[]).';
This will require that every spreadsheet indeed have identially the same number of elements or will fail spectacularly, though...while the other will succeed (albeit it gives up which set belongs to which original sheet if aren't same length) which is why did it that way originally.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Data Import from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!