MATLAB: How to skip a blank file

.csv fileblank fileimport

I am importing a mass of files and am processing them, however a short way in there is a blank file so it imports but then the calculations cannot be performed on it and the loop stops.
How do I define if the file is blank either delete or ignore the file then carry on to import the rest of the data?
Below is my script:
%% Import data
numfiles = 10; % number of excel files mydata=cell(numfiles,1); % defining size of mydata
for i=1:length(mydata) % loop to import mutliple excel files
myfilename = sprintf('Trial%i.csv', i); % define file name
mydata{i} = xlsread(myfilename); % import files into mydata
%% Perfrom Calculations
%%Define variables
a= 9.81; % acceleration
fps = 250; % frames per second
%%Calculate Jump Height
no_of_zeros = size(mydata{i,1},1) - nnz(mydata{i,1}(:,5)); %number of zeros
no_of_frames = (no_of_zeros/4); % number of frames
time = ((no_of_frames/fps)/2); % time up
jumph(i,1)=((a*(time*time))/2); % jump height
%%Calculate peak power
loc = find(mydata{i,1}(:,5)==0); loc = loc(1); % returns all the occurences of zero from column 5, then extracts the first
peakp(i,1) = nanmin (mydata {i,1}(1:loc,5)); % finding peak power from E1 to index cell
%%Calculate average power
avp(i,1) = nanmean (mydata {i,1}(1:loc,5)); % finding average power in column 5
%%Plot Results
figure(1);
subplot (1,3,1);
plot (avp);
%subplot (1,3,2);
%plot (b,c);
%subplot (1,3,3);
%plot (a,c);
title 'Random Graphs'
end
This is the error:
Error using xlsread (line 247) File C:\Users\Caz\Documents\MATLAB\coursework\Trial6.CSV not in Microsoft Excel Format.
Error in MatlabCoursework (line 15) mydata{i} = xlsread(myfilename); % import files into mydata
On opening the Trial6 document outside Matlab it is blank.

Best Answer

If the csv file is "blank" will the file size be zero? If so, you can use dir() to check the file sizes.