
Discussion BoardsOpen MenuDiscussion Boards Open Menu
 Notebook Gaming (Read Only)
 TX/TM Series Notebooks (Read Only)
 Notebook TV Tuners & Media Center (Read Only)
 Desktop Gaming (Read Only)
 Desktop Recovery (Read Only)
 Desktop CD & DVD (Read Only)
 Desktop PC Sound and Audio (Read Only)
 Windows® 7 Beta and Test (Read Only)
 Windows® 8 Release Preview (Read Only)
 Windows® 10 Technical Preview (Read Only)
 Commercial Desktop and Workstation (Read Only)
 Commercial Printers and AllInOnes (Read Only)
 Commercial PC Software (Read Only)
 Printers and AllInOnes (Read Only)
 Printer Networking and Wireless (Read Only)
 Ink, Toner, Cartridge, & Printhead Issues (Read Only)
 Web Printing Software (Read Only)
 Mac Printing and Scanning (Read Only)
 Other Printing Questions (Read Only)
 webOS Hardware and Software (Read Only)
 Other HP Consumer Products and Technologies (Read Only)

BlogsOpen Menu
 HP Support Forum Home
 >
 Tablets & Calculators
 >
 Calculators
 >
 Re: HP50g  subset of a matrix  how to
HP Support Forums
Join in the conversation.
 Subscribe
 Mark Topic as New
 Mark Topic as Read
 Float this Topic to the Top
 Bookmark
 Subscribe
 Printer Friendly Page
HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Report Inappropriate Content
07082014 03:30 AM
Could somebody give an example how to extract a subset of a matrix, say extract a double column matrix from NxM matrix?
I have data in NxM matrix and want to perform approximation with LAGRANGE command, which needs a 2 column input data. For example from 3x4 matrix
1 1 1 2
2 4 8 4
3 9 27 6
extract columns 1 & 3, ie. get 3x2 matrix
1 1
2 8
3 27
Thanks
Re: HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Report Inappropriate Content
07082014 06:23 AM
I doubt this is the simplest way, but at least it works. Just put your matrix on the stack then do this:
DUP
{1 3} {3 3} SUB
{1 2} SWAP REPL
{1 1} {3 2} SUB
> [[1 1] [2 8] [3 27]] as requested.
For more information about the SUB and REPL commands, see the Advanced Users Reference Manual, pages 3242 and 3199, respecively. Other useful commands for column work are >COL, COL>, COL, and COL+ (pages 339 and 340).
Re: HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Report Inappropriate Content
07082014 03:52 PM
Thank you Joe. Your solution works. After a few tests I picked another way with CSWP command. For the special case above it would be something like
<< 2 3 CSWP {1 1} {3 2} SUB >>
In general it could be something like
<< > T I
<< T 2 I CSWP DUP
SIZE 1GET 2 2 >LIST
{1 1} SUB
>>
>>
Program takes 2 parameters: matrix T and column number I, then extracts two columns (1 and I) from T matrix. In column 1 are x'es, in other columns are values for approximation. The line with SIZE, GET and >LIST is to detetrmine number of rows of the matrix (I don't know simpler way :)
BTW, SCATRPLOT takes 2 columns from NxM matrix
Thank you for the hint.
Re: HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Report Inappropriate Content
07092014 08:44 AM
You can also use the COL command ( MTH MATRIX COL COL ).
Removes the desired column number from the matrix, returning new matrix and deleted column as a vector.
Here's a simple program.
Matrix is on Level 2 and a list of columns to delete is on level 1:
<<
SORT LIST> > n
<< n 1 + PICK
1 n FOR j
SWAP COL DROP
NEXT
>>
>>
So this:
returns this:
Note: I do not work for HP, I just like playing with calculators :)
Re: HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Report Inappropriate Content
07092014 11:10 PM
Here's another approach to Bart's program. Same inputs.
<< SORT REVLIST 1 << COL DROP >> DOLIST >>
Unlike Bart's program, however, this only returns the new (smaller) matrix; the original is lost.
Re: HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Report Inappropriate Content
07102014 04:15 AM
Joseph Horn wrote:<< SORT REVLIST 1 << COL DROP >> DOLIST >>
Brilliant solution Joe. I sometimes forget the 50g has recursive commands like DOLIST.
Joseph Horn wrote:Unlike Bart's program, however, this only returns the new (smaller) matrix; the original is lost.
That's because I used PICK instead of ROLL, but usually only the answer is required anyway  so your solution is "cleaner" :).
Note: I do not work for HP, I just like playing with calculators :)