help-octave
[Top][All Lists]

## RE: some multi-dimensional matrix problem

 From: Hall, Benjamin Subject: RE: some multi-dimensional matrix problem Date: Mon, 24 May 2004 08:57:40 -0400

```Another option is

squeeze(p)

-----Original Message-----
Sent: Friday, May 21, 2004 5:22 PM
To: Bart Vandewoestyne
Subject: Re: some multi-dimensional matrix problem

Hi Bart,

something like:

octave:5> p = randn (1,3,4), res = reshape (p,3,4)
p =

ans(:,:,1) =

-0.56687   0.46960   1.76420

ans(:,:,2) =

-0.62780   0.10564  -0.21290

ans(:,:,3) =

-0.18718   0.34680   0.66555

ans(:,:,4) =

0.523143  -0.486609   0.042819

res =

-0.566865  -0.627797  -0.187179   0.523143
0.469599   0.105643   0.346800  -0.486609
1.764205  -0.212903   0.665555   0.042819

Hth,

Etienne

On Fri, May 21, 2004 at 04:02:30AM -0500, Bart Vandewoestyne wrote:
# Suppose you had a multi-dimensional matrix p that looked like:
#
# >> p
#
# p(:,:,1) =
#
#     0.8995    0.3137    0.2517    0.4330    0.8424
#
#
# p(:,:,2) =
#
#     0.1845    0.5082    0.4522    0.3256    0.3801
#
# I'm sure from my calculations that p(:,:,x) is always a 1xN vector.
# Now I want to combine all these 1xN vectors into a single result matrix,
# and I'm currently doing it like this (M is the max last dimension of p):
#
# for j=1:M,
#   res(j,:) = p(:,:,j);
# end
#
# which gives me what i want, but I was wondering if there's a faster,
# more vectorized way...
#
# Thanks,
# Bart
#
# --
# !!!!!!!!!!!!!!!!!!! email change !!!!!!!!!!!!!!!!!!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#
#
# -------------------------------------------------------------
# Octave is freely available under the terms of the GNU GPL.
#
# Octave's home on the web:  http://www.octave.org
# How to fund new projects:  http://www.octave.org/funding.html
# Subscription information:  http://www.octave.org/archive.html
# -------------------------------------------------------------
#

--
Etienne Grossmann ------ http://www.cs.uky.edu/~etienne

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

```