cancel
Showing results for
Did you mean:
Level 3
55 44 0 6
Message 1 of 5
737
Flag Post

# Split a vector into multiple variables

HP Recommended
HO 50G
Other

Tools like Solve linear system return the result in some kind of array/vector/matrix.

How can I steal each of the items of this vector and store them on different variables ?

Example:

Solutions: [[(0123)][(5555)]]

I need to store 0123 on variable A and 5555 on variable B

Possible ?

Tags (2)
4 REPLIES 4
Level 8
634 621 121 213
Message 2 of 5
Flag Post
HP Recommended

If you keep your 50g in Algebraic mode, please ignore this reply, since it assumes that you're in RPN mode.

Here are two ways to extract the contents of a vector or matrix:

Method #1: The OBJ→  command (in the PRG TYPE menu) explodes all the elements of a vector or matrix onto the stack, and leaves the dimensions on level 1.

Method #2: The V→  command (in the MTH VECTOR menu) explodes a vector's elements onto the stack, without leaving the dimension on the stack.

After using either of the above methods, storing the separate stack levels into variables is straightforward.

Hope that helps!  Disclaimer: I don't work for HP. I'm just another happy HP calculator user.

-Joe-
Level 3
55 44 0 6
Message 3 of 5
Flag Post
HP Recommended

No way to adapt this solution to algebraic ?

Maybe tweaking this attempt of mine ?

Level 3
55 44 0 6
Message 4 of 5
Flag Post
HP Recommended

Any chance to adapt these tools to algebraic ?

Indeed, they didn't work...

Level 6
140 139 29 60
Message 5 of 5
Flag Post
HP Recommended

There's not much in the way of documentation or "community expertise" with regards to using the 50g in algebraic mode.  The time spent becoming familiar with RPN mode usually pays off immensely in terms of documentation, tools, and user assistance from others using their 50g in similar ways.  I would strongly encourage you to consider using RPN mode to get the most out of your calculator.

That said, I believe the first problem you ran into is that OBJ→ in the first case is acting on the "outermost object grouping", which in this case is the tagged-composite level.  The result of OBJ→ in this situation is to split the tag apart from its encapsulated object (the matrix in this case).  You can see that in the result.  Using DTAG first, then OBJ→ will give you the actual output that you need, but note that the resulting list contains an embedded list with the dimensions of the original matrix.  So you'll have to deal with that in subsequent operations (see the SUB command for specifying the needed range of list contents).

V→ doesn't care about the tag ("Solutions"), but it's looking for a vector, and you're passing it single-column matrix instead.  That's the reason for the error for that attempt.

This would be a bit easier in RPN mode, but would still take several steps.  The end result would be easy to store in global variables simply by providing a list of those variable names to the STO command.  I'm not sure if that's even possible with algebraic mode, however.

† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation