Thread Subject: 1d array from a multidimensional array

Subject: 1d array from a multidimensional array

From: David Doria

Date: 9 Sep, 2007 20:39:35

Message: 1 of 4

i have an array that i index with 3 numbers:
ie.
Normalized_Moment_Values(1, 1, 1) returns a double

however, now i want everything with the first 2 index = [1
1], ie

Normalized_Moment_Values(1, 1, :) - but this doesn't seem to
be working, it is giving me

Normalized_Moment_Values(1, 1, :)

ans(:,:,1) =

    1.0693


ans(:,:,2) =

    1.4594


ans(:,:,3) =

   -0.5926

instead of a normal 1d vector

what do i do?

Thanks

David

Subject: 1d array from a multidimensional array

From: First Last

Date: 9 Sep, 2007 20:54:45

Message: 2 of 4

The hack is:

reshape(Normalized_Moment_Values(1,1,:),1,3)

for instance ... probably a better solution exists!

"David Doria" <daviddoria@gmail.com> wrote in message
<fc1lm7$69g$1@fred.mathworks.com>...
> i have an array that i index with 3 numbers:
> ie.
> Normalized_Moment_Values(1, 1, 1) returns a double
>
> however, now i want everything with the first 2 index = [1
> 1], ie
>
> Normalized_Moment_Values(1, 1, :) - but this doesn't seem to
> be working, it is giving me
>
> Normalized_Moment_Values(1, 1, :)
>
> ans(:,:,1) =
>
> 1.0693
>
>
> ans(:,:,2) =
>
> 1.4594
>
>
> ans(:,:,3) =
>
> -0.5926
>
> instead of a normal 1d vector
>
> what do i do?
>
> Thanks
>
> David

Subject: 1d array from a multidimensional array

From: David Doria

Date: 9 Sep, 2007 21:38:43

Message: 3 of 4

great! that works!! is there infact a better way as he says
though?

"First Last" <nospam@nospamplease.com> wrote in message
<fc1mil$d99$1@fred.mathworks.com>...
> The hack is:
>
> reshape(Normalized_Moment_Values(1,1,:),1,3)
>
> for instance ... probably a better solution exists!
>
> "David Doria" <daviddoria@gmail.com> wrote in message
> <fc1lm7$69g$1@fred.mathworks.com>...
> > i have an array that i index with 3 numbers:
> > ie.
> > Normalized_Moment_Values(1, 1, 1) returns a double
> >
> > however, now i want everything with the first 2 index = [1
> > 1], ie
> >
> > Normalized_Moment_Values(1, 1, :) - but this doesn't seem to
> > be working, it is giving me
> >
> > Normalized_Moment_Values(1, 1, :)
> >
> > ans(:,:,1) =
> >
> > 1.0693
> >
> >
> > ans(:,:,2) =
> >
> > 1.4594
> >
> >
> > ans(:,:,3) =
> >
> > -0.5926
> >
> > instead of a normal 1d vector
> >
> > what do i do?
> >
> > Thanks
> >
> > David
>

Subject: 1d array from a multidimensional array

From: John D'Errico

Date: 9 Sep, 2007 22:06:53

Message: 4 of 4

"David Doria" <daviddoria@gmail.com> wrote in message <fc1p52$3il
$1@fred.mathworks.com>...
> great! that works!! is there infact a better way as he says
> though?

squeeze

John

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com