Is there is easy command in matlab which prevents program from crashing when it reads characters?
I use xlsread
to read a (20 400) matrix data , the first row and column get disregarded
as they have headers, so that:
data = xlsread ( ' C:\file.xls')
results in data
with a size of (19 399).
I have a problem, some cells have missing data and it's written ' missing' and on some data sets i have headers reappear in middle.
Is there a way to skip these characters without the program crashing and me having to open the file in excel and deleting those fields?
Thanks
sorry for the late update here is the code i am using
[a,patha]=uigetfile({'*.csv'},'Select the file ,'c:\ Data\2010');
file1=[patha a];
%# get a file ID
fid = fopen(file1,'rt');
newf= textscan(fid, ['%s' repmat('%f',1,27)], 'HeaderLines', 1, 'Delimiter', ',');
fclose(fid) ;
%//Make time a datenum of the first column
time = datenum(newf{1} ); %//Find the difference in minutes from each row
timeDiff = round(diff(datenum(time)*(24*60)));
%//the rest of the data
newf = cell2mat(newf(2:28));
the error i get is
??? Error using ==> cat CAT arguments dimensions are not consistent.
Error in ==> cell2mat at 81 m{n} = cat(2,c{n,:});
Error in ==> testprogram at 31 pwr = cell2mat(newf(2:28));
it is due to the characters in my file i selected. it disaapears when i manually delete them