Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How can I manage the multidimensional array e.g., a{1,1}{2,2}

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: antnio

Date: 29 Jul, 2012 09:14:10

Message: 1 of 7

I am introducing cell array format like
T = 10;
for t = 1 : T
F{1,2}{6,t} = [0 0 0];
end

I want to change only the dimension along parameter "t" e.g.,
from t = 5 to t = 8
F{1,2}{6,5} = [1 1 1];
F{1,2}{6,6} = [1 1 1];
F{1,2}{6,7} = [1 1 1];

What I dd try,

F{1,2}{6, 5:7} = [1 1 1];

It does not work, it returns

The right hand side of this assignment has too few values to satisfy the left hand side.

Could any one please suggest me, how could I resolve this problem?

I have really no idea if I am using F{}{}, what this "F{}{}" called. Therefoe, I cannot search for help properly.

Thank you in advance.
Antonio

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: Bruno Luong

Date: 29 Jul, 2012 09:25:13

Message: 2 of 7

"antnio " <a@mail.com> wrote in message <jv2ut1$jc6$1@newscl01ah.mathworks.com>...
> I am introducing cell array format like
> T = 10;
> for t = 1 : T
> F{1,2}{6,t} = [0 0 0];
> end
>
> I want to change only the dimension along parameter "t" e.g.,
> from t = 5 to t = 8
> F{1,2}{6,5} = [1 1 1];
> F{1,2}{6,6} = [1 1 1];
> F{1,2}{6,7} = [1 1 1];
>
> What I dd try,
>
> F{1,2}{6, 5:7} = [1 1 1];

Use
F{1,2}{6, 5:7} = deal([1 1 1]);

A strong advise though: CELL array is slow and nasty to work with. Before going too far, ask yourself if you really need to store your data that way.

Bruno

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: Bruno Luong

Date: 29 Jul, 2012 09:55:14

Message: 3 of 7

Sorry for the typo, should be:
>
> Use
> [F{1,2}{6, 5:7}] = deal([1 1 1]);
>

Or alternatively

F{1,2}(6, 5:7) = {[1 1 1]};

% Bruno

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: Antonio Valentine

Date: 29 Jul, 2012 13:46:14

Message: 4 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jv2vhp$ln9$1@newscl01ah.mathworks.com>...
> "antnio " <a@mail.com> wrote in message <jv2ut1$jc6$1@newscl01ah.mathworks.com>...
> > I am introducing cell array format like
> > T = 10;
> > for t = 1 : T
> > F{1,2}{6,t} = [0 0 0];
> > end
> >
> > I want to change only the dimension along parameter "t" e.g.,
> > from t = 5 to t = 8
> > F{1,2}{6,5} = [1 1 1];
> > F{1,2}{6,6} = [1 1 1];
> > F{1,2}{6,7} = [1 1 1];
> >
> > What I dd try,
> >
> > F{1,2}{6, 5:7} = [1 1 1];
>
> Use
> F{1,2}{6, 5:7} = deal([1 1 1]);
>
> A strong advise though: CELL array is slow and nasty to work with. Before going too far, ask yourself if you really need to store your data that way.
>
> Bruno


Thank you very much Bruno,

I will try and let you know the result.
However, I have to use this type of array because I have 3 vectors that have different dimension. 37x1, 40x1 and 49x1, respectively.

If you say cell array will make the program more slower, do you have any suggestions?

I have to create a program for 4 variables: i j k m

I am not preferred to run "for loop" for 4 variables.

Thank you in advance.

Antonio

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: Bruno Luong

Date: 29 Jul, 2012 14:48:15

Message: 5 of 7

"Antonio Valentine" <chanloha@gmail.com> wrote in message <jv3er6$c1l$1@newscl01ah.mathworks.com>...

>
> If you say cell array will make the program more slower, do you have any suggestions?

No, because I don't know what kind of data manipulation you would do downstream.

Bruno

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: Antonio Valentine

Date: 29 Jul, 2012 15:30:24

Message: 6 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jv3ife$niu$1@newscl01ah.mathworks.com>...
> "Antonio Valentine" <chanloha@gmail.com> wrote in message <jv3er6$c1l$1@newscl01ah.mathworks.com>...
>
> >
> > If you say cell array will make the program more slower, do you have any suggestions?
>
> No, because I don't know what kind of data manipulation you would do downstream.
>
> Bruno


Basically, all the cell array will use only summation, subtraction and comparison( min operator). Only that.

The hardest part was what I asked here.

I am trying to do like your suggestion. will let you know soon.

Subject: How can I manage the multidimensional array e.g., a{1,1}{2,2}

From: Antonio Valentine

Date: 29 Jul, 2012 16:26:12

Message: 7 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jv31a2$rcf$1@newscl01ah.mathworks.com>...
> Sorry for the typo, should be:
> >
> > Use
> > [F{1,2}{6, 5:7}] = deal([1 1 1]);
> >
>
> Or alternatively
>
> F{1,2}(6, 5:7) = {[1 1 1]};
>
> % Bruno

Perfect!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us