필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I import multiple Excel files?

조회 수: 1 (최근 30일)
Asher Zaidi
Asher Zaidi 2018년 6월 6일
마감: Asher Zaidi 2018년 6월 6일
files = dir('*.xls');
for i=1:length(files)
x = eval(['importdata(files(i).name)']);
z1 = x.data(:,5); %grabs column 5 from x.data
z2 = x.data(:,6); %grabs column 6 from x.data
%%obtains value closest to 0 in column 'z2'
numb=0;
[~, imin] = min(abs(z2 - numb));
value(i) = z2(imin)
plot(z1,z2)
end
When trying to run the code above, I get this error
>> test2
Warning: File contains uninterpretable data.
> In importdata (line 144)
In test2 (line 3)
Index in position 2 exceeds array bounds.
Error in test2 (line 4)
z1 = x.data(:,5); %grabs column 5 from x.data
However, if I attempt to import ".txt" files it works just fine. How can I import multiple excel files?
  댓글 수: 4
Asher Zaidi
Asher Zaidi 2018년 6월 6일
xlsread('1.xlsx')
Error using xlsread (line 260)
Invalid zip file "/MATLAB Drive/1.xlsx".
'xlsread()' gives this error above
Asher Zaidi
Asher Zaidi 2018년 6월 6일
I can confirm, after saving the file as an "Excel 97-2003 Workbook" (.xls), it began working fine. Thank you!

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by