help-octave
[Top][All Lists]
Advanced

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

Re: Multidimensional matrix


From: David Grundberg
Subject: Re: Multidimensional matrix
Date: Thu, 05 Nov 2009 10:53:05 +0100
User-agent: Thunderbird 2.0.0.21 (X11/20090302)

Alberto Frigerio wrote:
Hi everyone, I've some questions about multidimensional matrix.

*) It is possible to create (maybe using a list) a multidimensional matrix
A, i.e. every element of A is not a number but a couple, triplet, etc. of
numbers ?
*) How can I multiply two multidimensional matrices ?

Thanks everybody,
   Alberto

To create 3x3x8 double matrices, use something like:

A = [1 2 3; 4 5 6; 7 8 9];
A = repmat(A, [1, 1, 8]);
A

B = eye(3);
B = repmat(B, [1, 1, 8]);
# To make it more interesting, use indexing to change certain elements:
B(2,:,1:2) = 10;
B(2,:,3:4) = 100;
B(1,[1 3],5:6) = 1000;
B(1,[1 3],7:8) = 10000;
B(2,2,1:4) = -1;
B

#And to do element multiplication you could use the .* operator:
A .* B

hth
David


reply via email to

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