Help needed with a matrix



#2

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. ]]
'MAT'
STO

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]
2
ROW+

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. ]]
'MAT'
STO
MAT
['ABC' n]
2
ROW+

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.


#3

Hi, Karl;

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

[[12. 2.] [0. 0. ]]
'MAT'
STO
MAT
[['ABC' n]]
2
ROW+

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.

#4

[[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
[[VPN]]
#5

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 ?


#6

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.

#7

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 106 12-06-2013, 11:06 AM
Last Post: Joseph Ec
  HP Prime Matrix TERRIBLE bug and question uklo 19 384 11-25-2013, 12:10 PM
Last Post: Mic
  HP Prime: editing a matrix Alberto Candel 6 136 11-20-2013, 06:26 PM
Last Post: Helge Gabert
  Absolute Value and Matrix BruceTTT 5 147 11-11-2013, 11:52 PM
Last Post: Walter B
  WP-34S Matrix operations with routine-local registers? Tom Grydeland 1 76 09-04-2013, 10:46 AM
Last Post: Marcus von Cube, Germany
  Matrix Characteristic Polynomial - Reloaded. Ángel Martin 12 237 08-22-2013, 05:33 PM
Last Post: Thomas Klemm
  Matrix Richard Berler 3 104 08-18-2013, 06:24 PM
Last Post: Paul Dale
  Advantage/CCD Matrix Challenge Ángel Martin 1 73 08-09-2013, 06:22 PM
Last Post: Thomas Klemm
  [HP -Prime CAS] List, Matrix, Vector as one Array? CompSystems 0 51 07-26-2013, 05:22 PM
Last Post: CompSystems
  [OT?]Orthography corrector needed. Diego Diaz 8 169 06-22-2013, 04:31 PM
Last Post: Andrew Nikitin

Forum Jump: