help-octave
[Top][All Lists]

Re: Unidentified subject!

 From: Geraint Paul Bevan Subject: Re: Unidentified subject! Date: Fri, 30 Apr 2004 21:34:11 +0100 User-agent: Mozilla Thunderbird 0.5 (X11/20040306)

```-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

| Hi,
|
| I would like to define a function A(x). A(x) is really a 2x2 matrix.
| Therefore I need to assign A11, A12, A21 and A22. How can I do this in
| octave?
|
|

To define a matrix, enclose the values in square brackets:

octave:1> A = [ 1, 2; 3, 4 ]
A =

~  1  2
~  3  4

as described in the manual ('help -i matrices' at the octave prompt).

If you really need to make A appear to be a function, just create a
function that returns a matrix object:

octave:2> function a = A();
| a = [ 2, 4; 6, 8 ];
| endfunction

octave:3> A()
ans =

~  2  4
~  6  8

- --
Geraint Bevan
http://homepage.ntlworld.com/geraint.bevan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iEYEARECAAYFAkCSuEIACgkQcXV3N50QmNNjMACgj2r5zvJ0I6tIIijkao/3XHaX
UqEAnA7DGsCKFMsHdizL/LcZa8dIfgb4
=QjnQ
-----END PGP SIGNATURE-----

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

```