HP Forums
Taking part of a matrix. - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Taking part of a matrix. (/thread-17189.html)



Taking part of a matrix. - Isai - 06-30-2021 01:25 PM

Is there any way of take part of a matrix? For example in Matlab it could be A(i:j,m:n) to take from i to j rows and m to n columns.
I know that in HP Prime we could take an element of a matrix, A(i,j).


RE: Taking part of a matrix. - ijabbott - 06-30-2021 02:54 PM

(06-30-2021 01:25 PM)Isai Wrote:  Is there any way of take part of a matrix? For example in Matlab it could be A(i:j,m:n) to take from i to j rows and m to n columns.
I know that in HP Prime we could take an element of a matrix, A(i,j).

This operation is called "slicing" the matrix. I don't think there is anything built-in to do it, except in Python/Numpy.


RE: Taking part of a matrix. - robmio - 06-30-2021 03:22 PM

Hi, try using the "SUB" command:

"SUB (Matrix, {rowA, columnA}, {rowB, columnB})".

Look at the attachment.


RE: Taking part of a matrix. - Didier Lachieze - 06-30-2021 04:42 PM

(06-30-2021 01:25 PM)Isai Wrote:  Is there any way of take part of a matrix? For example in Matlab it could be A(i:j,m:n) to take from i to j rows and m to n columns.

From the section "Matrix references" in the Prime manual:
Quote:M1({{1,1},{2,2}}) extracts a sub-matrix from the element in the first row and column to the element in the second row and column.

So your Mathlab example for A(i:j,m:n) would translate on the Prime to M1({{i,m},{j,n}})