From: Wendy on
I want to create a nested cell with 3 levels, ie. A{}{}{}. I want to prelocate this cell, as I am going to use it as a counting tool using the code below:

OUTPUT{1,path_i}{1,Ka_i}{1,class_i} = OUTPUT{1,path_i}{1,Ka_i}{1,class_i}+1;

I need to initialize the cell. I tried OUTPUT=zeros{1:5}{1:4}{1:10}, but it does not work. Does anyone know how to initialize a nested cell? Or is there any suggestion for counting to avoid the use of existing value in a cell element?

Thank you very much,
Wendy
From: ade77 on
"Wendy " <wlq121(a)gmail.com> wrote in message <hki93k$7s6$1(a)fred.mathworks.com>...
> I want to create a nested cell with 3 levels, ie. A{}{}{}. I want to prelocate this cell, as I am going to use it as a counting tool using the code below:
>
> OUTPUT{1,path_i}{1,Ka_i}{1,class_i} = OUTPUT{1,path_i}{1,Ka_i}{1,class_i}+1;
>
> I need to initialize the cell. I tried OUTPUT=zeros{1:5}{1:4}{1:10}, but it does not work. Does anyone know how to initialize a nested cell? Or is there any suggestion for counting to avoid the use of existing value in a cell element?
>
> Thank you very much,
> Wendy

doc cell
From: James Tursa on
"Wendy " <wlq121(a)gmail.com> wrote in message <hki93k$7s6$1(a)fred.mathworks.com>...
> I want to create a nested cell with 3 levels, ie. A{}{}{}. I want to prelocate this cell, as I am going to use it as a counting tool using the code below:
>
> OUTPUT{1,path_i}{1,Ka_i}{1,class_i} = OUTPUT{1,path_i}{1,Ka_i}{1,class_i}+1;
>
> I need to initialize the cell. I tried OUTPUT=zeros{1:5}{1:4}{1:10}, but it does not work. Does anyone know how to initialize a nested cell? Or is there any suggestion for counting to avoid the use of existing value in a cell element?
>
> Thank you very much,
> Wendy

Why are you trying to use a cell as opposed to a multi-dimensional array? e.g., why not

OUTPUT = zeros(5,4,10);
:
OUTPUT(path_i,Ka_i,class_i) = OUTPUT(path_i,Ka_i,class_i)+1;

James Tursa
From: Jan Simon on
Dear Wendy!

> I want to create a nested cell with 3 levels, ie. A{}{}{}. I want to prelocate this cell, as I am going to use it as a counting tool using the code below:
>
> OUTPUT{1,path_i}{1,Ka_i}{1,class_i} = OUTPUT{1,path_i}{1,Ka_i}{1,class_i}+1;

> OUTPUT=zeros{1:5}{1:4}{1:10}
> but it does not work

This is not surprising, because it is obviously no valid Matlab syntax. Please look at: help zeros

You cannot pre-allocate nested cells in a single step. You have to do this for each level individually:
C3 = cell(1, class_n);
C3(:) = {1}; % fill in your wanted data here!
C2 = cell(1, Ka_n);
C2(:) = {C3};
C1 = cell(1, path_n);
C1(:) = {C2};

Nevertheless, I assume that there is a better method to organize your data that 3 nested cells.

Kind regards, Jan