Thread Subject: get a 1d vector from a multidimensional array

Subject: get a 1d vector from a multidimensional array

From: David Doria

Date: 9 Sep, 2007 20:35:19

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, I want all the things that correspond to (1,1,x),
so i usually do

Normalized_Moment_Values(1, 1, :)

however, this returns:

ans(:,:,1) =

    1.0693


ans(:,:,2) =

    1.4594


ans(:,:,3) =

   -0.5926


ans(:,:,4) =

    0.9791


and it wont put that into a 1d array, namely [1.06 1.4 -.59 .97]

how would i do this?

Thanks

David

Subject: get a 1d vector from a multidimensional array

From: dpb

Date: 9 Sep, 2007 20:43:32

Message: 2 of 4

David Doria wrote:
> i have an array that i index with 3 numbers, ie:
>
> Normalized_Moment_Values(1, 1, 1) returns a double
>
> However, I want all the things that correspond to (1,1,x),
> so i usually do
>
> Normalized_Moment_Values(1, 1, :)
>
> however, this returns:
>
> ans(:,:,1) =
>
> 1.0693
>
>
> ans(:,:,2) =
>
> 1.4594
>
>
> ans(:,:,3) =
>
> -0.5926
>
>
> ans(:,:,4) =
>
> 0.9791
>
>
> and it wont put that into a 1d array, namely [1.06 1.4 -.59 .97]
>
> how would i do this?
>

Does

» x=rand(3)
x =
     0.9501 0.4860 0.4565
     0.2311 0.8913 0.0185
     0.6068 0.7621 0.8214
» y=x(:,1)
y =
     0.9501
     0.2311
     0.6068
» z = y'
z =
     0.9501 0.2311 0.6068
»

give you any ideas???

--

Subject: get a 1d vector from a multidimensional array

From: David Doria

Date: 9 Sep, 2007 20:56:14

Message: 3 of 4

ummm no not really, that is how it usually works, but this
is not giving me a 1d thing back , it is giving me a 3d
thing, thats what i'm trying to avoid.

David


dpb <none@non.net> wrote in message <fc1m29$upv$1@aioe.org>...
> David Doria wrote:
> > i have an array that i index with 3 numbers, ie:
> >
> > Normalized_Moment_Values(1, 1, 1) returns a double
> >
> > However, I want all the things that correspond to (1,1,x),
> > so i usually do
> >
> > Normalized_Moment_Values(1, 1, :)
> >
> > however, this returns:
> >
> > ans(:,:,1) =
> >
> > 1.0693
> >
> >
> > ans(:,:,2) =
> >
> > 1.4594
> >
> >
> > ans(:,:,3) =
> >
> > -0.5926
> >
> >
> > ans(:,:,4) =
> >
> > 0.9791
> >
> >
> > and it wont put that into a 1d array, namely [1.06 1.4
-.59 .97]
> >
> > how would i do this?
> >
>
> Does
>
> » x=rand(3)
> x =
> 0.9501 0.4860 0.4565
> 0.2311 0.8913 0.0185
> 0.6068 0.7621 0.8214
> » y=x(:,1)
> y =
> 0.9501
> 0.2311
> 0.6068
> » z = y'
> z =
> 0.9501 0.2311 0.6068
> »
>
> give you any ideas???
>
> --

Subject: get a 1d vector from a multidimensional array

From: us

Date: 9 Sep, 2007 22:15:15

Message: 4 of 4

David Doria:
<SNIP should squeeze his/her children...

one of the solutions

     v=rand(2,3,3)
     vs=squeeze(v(1,1,:))

us

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
code us 9 Sep, 2007 18:20:20
squeeze us 9 Sep, 2007 18:20:20
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