Help needed with a matrix


I need some help with the programmatic creation of a matrix as well as storing and recalling values to it. I created a matrix with the following steps:

[[12. 2.] [0. 0. ]]

This worked and created the matrix named "MAT". Then I tried to insert a row after the row [12. 2.] with the string "ABC" and the value 2004. I succeeded by entering the following in RUN-Mode:

MAT (resulting in recalling the matrix MAT to the stack)
['ABC' 2004]

Now doing the same from within a UserRPL program with a slight modification always results in an error. The modification ist that the value 2004 should come from a local variable named n:

[[12. 2.] [0. 0. ]]
['ABC' n]

This results in a syntax error. All my attempts to create ['ABC' 2004] on the stack with 2004 coming from variable n failed. The users manual from the CD was no help at all (how I wish back the times when HP really could be proud of their user manuals like the one for the HP-67/97).

Later on in the program I need to recall individual values from the matrix as well as storing new values in already existing cells.

How can I acomplish these task ? Maybe there is a really good tutorial somewhere on the Internet ? Any hint will be very much appreciated - thank you very much in advance.


Hi, Karl;

I used an HP49G+, O.K.? I tried this and it worked:

[[12. 2.] [0. 0. ]]
[['ABC' n]]

The resulting object is:

[[12. 2.]
[ABC n]
[0. 0. ]]

Note that the object to be added as a new row is a matrix. It seems that ROW+ expects a matrix (or a single-row matrix) instead of a 2-D vector.

Hope this helps.

Luiz (Brazil)

Edited: 7 Aug 2004, 4:10 p.m.


[[12. 2.] [0. 0. ]] 'MAT' STO MAT ['ABC' n] 2 ROW+
2004 -> n <<
[[12. 2.] [0. 0. ]] 'MAT' STO MAT
'ABC' n 2 ->ARRY 2 ROW+
>> @ now the value of n is there

Thanks both of you for your answers. The solutions work like a charm. I'm going to use this for a short routine that can be used to log values of local variables for debugging and reference purposes. By the way, is there a method of detecting the presence of a global matrix variable ? For the short routine I'm planning I need to know if the matrix already exits or if the program has to create it first ?


You could probably just use:

'VarName' STO
If VarName already exists in the current directory, then it will be overwritten, if it doesn't exist in the current directory, then it will be created.

But if you want to avoid overwriting VarName, use the VTYPE command.

'VarName' VTYPE
returns the type of object stored in the variable if it's found, or -1 if it doesn't exist in the current path.


Thank you, James, the second method you describe is the one of choice in this case 'cause I wouldn't want to overwrite an existing matrix.

Possibly Related Threads...
Thread Author Replies Views Last Post
  AFTER HP-Prime update, Shift+Matrix CRASHES Joseph Ec 3 1,427 12-06-2013, 11:06 AM
Last Post: Joseph Ec
  HP Prime Matrix TERRIBLE bug and question uklo 19 3,512 11-25-2013, 12:10 PM
Last Post: Mic
  HP Prime: editing a matrix Alberto Candel 6 1,722 11-20-2013, 06:26 PM
Last Post: Helge Gabert
  Absolute Value and Matrix BruceTTT 5 1,569 11-11-2013, 11:52 PM
Last Post: Walter B
  WP-34S Matrix operations with routine-local registers? Tom Grydeland 1 891 09-04-2013, 10:46 AM
Last Post: Marcus von Cube, Germany
  Matrix Characteristic Polynomial - Reloaded. Ángel Martin 12 2,483 08-22-2013, 05:33 PM
Last Post: Thomas Klemm
  Matrix Richard Berler 3 1,079 08-18-2013, 06:24 PM
Last Post: Paul Dale
  Advantage/CCD Matrix Challenge Ángel Martin 1 884 08-09-2013, 06:22 PM
Last Post: Thomas Klemm
  [HP -Prime CAS] List, Matrix, Vector as one Array? CompSystems 0 735 07-26-2013, 05:22 PM
Last Post: CompSystems
  [OT?]Orthography corrector needed. Diego Diaz 8 1,931 06-22-2013, 04:31 PM
Last Post: Andrew Nikitin

Forum Jump: