MATLAB: How to resolve the error “cell contents reference from a non-cell array object”? Thank you!!

cell contents reference from a non-cell array object

Looking for help on my project. Any help is largely appraciated!!
fid = fopen('test.cal');
[paramlist l] = textscan(fid, '%s %s %s %s %s');
fclose(fid);
[len wid] = size(paramlist{1}); %[len wid]=[18 1]
j = 1;
chanlist = cell(1,len); %create a cell array named chanlist
for i=1:len
if(strcmp(paramlist{1}{i},'channel'));
chanlist{1,j} = {paramlist{2}{i},paramlist{3}{i},paramlist{4}{i},paramlist{5}{i}};
disp(chanlist{1,j});
j=j+1;
end
end
for i=1:len
if(strcmp(chanlist{i}{1}, 'DIGOUT'))%%when I run the code, it shows error happens here
if (str2double(chanlist{i}{3}) < 28) %28 digital IOs on a minilab1008

if (strcmp(chanlist{i}{2}, '0'))
disp('board 0 DIGOUT');
elseif (strcmp(chanlist{i}{2},'1'))
disp('board 1 DIGOUT');
else 'only boards 0 and 1 supported';
end
else 'ignoring digital output';
end
elseif strcmp(chanlist{i}{1}, 'DIGIN')
if (str2double(chanlist{i}{3}) < 28) %28 digital IOs on a minilab1008
if (strcmp(chanlist{i}{2}, '0'))
disp('board 0 DIGIN');
elseif (strcmp(chanlist{i}{2},'1'))
disp('board 1 DIGIN');
else 'only boards 0 and 1 supported';
end;
else 'ignoring digital output';
end;
end
end
Here is the "test.cal" file: (3rd column represents board number, 4th column represents line/channel number)
channel DIGOUT 0 0 shutter1
channel DIGOUT 0 1 shutter2
channel DIGOUT 0 2 shutter3
channel DIGOUT 0 3 shutter4
channel DIGOUT 1 0 shutter5
channel DIGIN 0 4 shutter1state
channel DIGIN 0 5 shutter2state
channel DIGIN 0 6 shutter3state
channel DIGIN 0 7 shutter4state
channel DIGIN 1 1 shutter5state
channel ANAOUT 0 0 TempCtrlVolt
channel ANAOUT 0 1 PositionCtrlVolt
channel ANAOUT 1 0 TempCtrlVolt
channel ANAIN 0 0 PSUVolt
channel ANAIN 0 1 PositionCtrlState
channel ANAIN 1 0 PSUVolt
calib TempCtrlVolt 0 120
calib TempCtrlVolt 1 120

Best Answer

Check the type of chanlist{i} by setting either a breakpoint in the failing line or let the debugger stop Matlab in case of errors:
dbstop if error
The next problem will occur, when you check chanlist{i}{3} < 28: You've imported all data using the '%s' format in textscan. Therefore you cannot find numeric data in the cells.