Cell contents reference from a non-cell array object.?

Hello
I have a 1x1 struct small with the fields
small.bound5 with 1x20 cells (each cell with 2 variables
small.bound10 1x 20cells (each cells with 2 variables
small.average 1x 20 cells (each cell with one variable
small.data (1x20 cells) (each cells with 288x1 colum of data)
I am trying to excecute the following code and keep getting the error. I understand that i am referencing some thing wrong. PLEASE HELP
% code
crit=.1;
for i = 1:length(small.average)
for j=1:length(small.bound5{i})
if small.bound5{i}{j}(1)>=small.average{i}*(1-crit) && small.bound5{i}{j}(2)<=small.average{i}*(1+crit)
count(i,j)=1;
else
count(i,j)=0;
end
end
end
for j=1:length(small.bound5{i})
pin(j)=sum(count(:,j))/length(count(:,j));
end
figure3=figure;
axes3=axes('parent',figure3);
plot(full,pin,'x-k')
ylabel(['percent of dogs with match of <',num2str(crit*100),'%'],'fontsize',lfont)
xlabel('timestep (hr)','fontsize',lfont)
I am getting the error with the line,
small.bound5{i}{j}(1)>=small.average{i}*(1-crit) && small.bound5{i}{j}(2)<=small.average{i}*(1+crit)
The error

Risposte (1)

small.bound5 is a 1-D cell array. A 1-d vector of 20 cells. It is NOT a 2-D matrix of cells. So you can't do small.bound5{i}{j} which assumes that it's a 2-D array. You can only use one index with it, not 2. See the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

Categorie

Scopri di più su Functions in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by