필터 지우기
필터 지우기

Blank files need to be skipped

조회 수: 2 (최근 30일)
Franchesca
Franchesca 2014년 5월 13일
답변: Image Analyst 2014년 5월 13일
%%Import data
numfiles = 54; % number of excel files
mydata=cell(numfiles,1); % defining size of mydata
grouped = xlsread('Group B File Info');
d=dir('Trial*.csv');
for i=1:length(mydata) % loop to import mutliple excel files
if d(i).bytes>10
mydata{i} = xlsread(d(i).name); % import files into mydata
else
disp([d(i).name 'read failed'])
end
myfilename = sprintf('Trial%02d.csv', i); % define file name
mydata{i} = xlsread(myfilename); % import files into mydata
That is my code and this is the error I am recieving:
Error using xlsread (line 247)
File C:\Users\Caz\Documents\MATLAB\coursework\Trial06.CSV not in Microsoft Excel Format.
Error in MatlabCoursework (line 23) mydata{i} = xlsread(myfilename); % import files into mydata
Trial06.CSV is in the folder in the same format as all the other trials, however it is blank which is why the if, else was added incase of a blank file.
How do I overcome this?

채택된 답변

Image Analyst
Image Analyst 2014년 5월 13일
Try
if d(i).bytes>0

추가 답변 (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