help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating 3D matrices


From: John W. Eaton
Subject: Creating 3D matrices
Date: Thu, 17 Nov 2005 21:25:28 -0500

On 17-Nov-2005, Colin Ingram wrote:

| I've been having some problems working with 3D matrices.  I'll start
| with the easy stuff.
| 
| Is there a better way to make a matrix of indices in the third dimension
| than this?
| 
| X = 50;
| Y = 80;
| Z = 100;
| matrix = zeroes(X,Y,Z);
| for i = [1:Z]
|     matrix(:,:,i)=i*ones(X,Y);
| endfor

  repmat (reshape (1:Z, [1, 1, Z]), [X, Y, 1])

| on a similar note is there a better to build this matrix
| 
| X = 50;
| Y = 80;
| Z = 100;
| randmat = rand(X,Y);
| matrix = zeroes(X,Y,Z);
| for i = [1,Z]
|     matrix(:,:,i)=randmat;
| endfor

  repmat (rand (X, Y), [1, 1, Z])

jwe



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]