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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com