HP Forums
Creating matrix on HP 50g - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Creating matrix on HP 50g (/thread-3739.html)



Creating matrix on HP 50g - Cancuino - 04-29-2015 01:01 PM

Hi, I'm programming something where I need to create a 6x6 matrix, I have all the 36 values that I must fill the matrix with. Which is the best command for this?.

Thank you.


RE: Creating matrix on HP 50g - Tugdual - 04-29-2015 01:49 PM

(04-29-2015 01:01 PM)Cancuino Wrote:  Hi, I'm programming something where I need to create a 6x6 matrix, I have all the 36 values that I must fill the matrix with. Which is the best command for this?.

Thank you.
Depends on your starting point.

Starting from values
If you enter $$\begin{pmatrix} 11 & 12 \\ 21 & 22 \end{pmatrix}$$ and then call OBJ→ you'll see that the stack contains
11
12
21
22
{2 2}
So you can just push all items in this specific order in the stack call
If you now call →ARRY matrix is back.

Starting from vectors
Push all vectors in the stack and then the # of vectors
[11 21]
[12 22]
2
call COL→
Here we go...


RE: Creating matrix on HP 50g - Cancuino - 04-29-2015 01:59 PM

Thank you Tugdual, I'll try that.
I'm making my program with the PUTI command but just testing right now.


RE: Creating matrix on HP 50g - Gilles - 04-29-2015 02:26 PM

(04-29-2015 01:01 PM)Cancuino Wrote:  Hi, I'm programming something where I need to create a 6x6 matrix, I have all the 36 values that I must fill the matrix with. Which is the best command for this?.

Thank you.

Hi there many ways for this. in addition of Tuagal post :

1/ If you know the elements of the matrix, just enter it in your program :
[[ 11 21 ] [ 12 22]]

2/ Create a 6x6 identity matrix :
6 IDN

3/ If each element is a function of I J (Line, Column)
6 6 « 10 * + » LCXM @ Create a 6x6 matrix [[ 11 21 31 ...] [12 22 32 ...] ... ]

4/ If your matrice is a variable, for example M you can use this syntax
99 'M(3,5)' STO
`M(I,J)` returns immediatly the value of I columns J row of M
Slower but more readable in many cases than the PUT and GET command

Etc.


RE: Creating matrix on HP 50g - Cancuino - 04-29-2015 05:00 PM

The elements of the matrix are variables, and the matrix should be created with them.


RE: Creating matrix on HP 50g - Cancuino - 04-29-2015 05:47 PM

Here's another one.
The program that creates the matrix is done, let's name it "MATRIX".
Now I have a FOR loop, for example from 1 to 3, so that it calls MATRIX three times and creates three matrixes. I want to store every matrix according to the FOR index, the first iteration would store the K1 matrix, the second K2 and the third K3.
How can I do this?.

Thank you.


RE: Creating matrix on HP 50g - Tugdual - 04-29-2015 06:29 PM

(04-29-2015 05:47 PM)Cancuino Wrote:  Here's another one.
The program that creates the matrix is done, let's name it "MATRIX".
Now I have a FOR loop, for example from 1 to 3, so that it calls MATRIX three times and creates three matrixes. I want to store every matrix according to the FOR index, the first iteration would store the K1 matrix, the second K2 and the third K3.
How can I do this?.

Thank you.
Two solutions:
- you push them in stack one after the other and then call 3 consecutive STO
- you push them into a list named K which I think is the preferred approach with RPL


RE: Creating matrix on HP 50g - Cancuino - 04-29-2015 07:09 PM

What I don't know how to do is the number besides K, for example K2, I don't know how to set a counter that automatically names the variable Ki, being i=1, 2, 3, ...


RE: Creating matrix on HP 50g - Tugdual - 04-29-2015 08:07 PM

(04-29-2015 07:09 PM)Cancuino Wrote:  What I don't know how to do is the number besides K, for example K2, I don't know how to set a counter that automatically names the variable Ki, being i=1, 2, 3, ...
Do you need to?
Try this:
Create a matrix
Press enter twice to have 2 additional copies
Enter 3
Now choose →LIST

See? The 3 matrices are now in a list! Pretty cool isn't it?
Matrices are objects and you can store anything in lists then using GET with any index, you can retrieve a value.


RE: Creating matrix on HP 50g - Cancuino - 04-29-2015 08:34 PM

That's a great way to store them. Thank you Tugdual.
I'm trying to make everything automated, so that I end up with the three matrixes stored in three different variables.
I know how to decompose the list and store the matrixes but I can't figure out how to sort them.

Edit: I've finally found the way to do it. "K" i + creates "Ki" then I use ->OBJ and I have 'Ki', where I can store the matrix.