From: 德馬堤 <d00...@nt...> - 2024-05-03 19:31:38
|
Thank you, the following function does it: submat(M,rows,cols):= block( rows:subst(length(M),end,rows), cols:subst(length(M[1]),end,cols), transpose(apply(matrix,makelist(transpose(apply(matrix,makelist(M[i],i,rows[1],rows[2])))[j],j,cols[1],cols[2]))))$ For example: M:matrix([12, 3, 3],[2, 3, 4]); submat(M,[1,2],[1,2]); /* submat(matrix,[minrow, maxrow],[mincol,maxcol]) */ submat(M,[1,end-1],[1,end-2]) |