
Discussion BoardsOpen MenuDiscussion Boards Open Menu

BlogsOpen Menu

HP Notebook Battery Recall and ReplacementOpen MenuHP Notebook Battery Recall and Replacement Open Menu
In cooperation with various government regulatory agencies, HP has announced an expansion of its June 2016 worldwide voluntary safety recall and replacement program for certain notebook batteries. Additional batteries are affected.
 HP Support Forum Home
 >
 Tablets
 >
 Calculators
 >
 Re: HP50g  subset of a matrix  how to
 Subscribe
 Mark Topic as New
 Mark Topic as Read
 Float this Topic for Current User
 Bookmark
 Subscribe
 Printer Friendly Page
HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Email to a Friend
 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
 Email to a Friend
 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
 Email to a Friend
 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
 Email to a Friend
 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:
_________________________________________________________
calculator enthusiast
Re: HP50g  subset of a matrix  how to
 Mark as New
 Bookmark
 Subscribe
 Subscribe to RSS Feed
 Highlight
 Email to a Friend
 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
 Email to a Friend
 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" :).
_________________________________________________________
calculator enthusiast