Programming Question: How do you augment one matrix with another?
|
07-02-2014, 05:59 PM
Post: #7
|
|||
|
|||
RE: Programming Question: How do you augment one matrix with another?
Parisse: Could you give an explicit example of what you meant by "[op(M1),op(M2)] glues two matrices together", preferably that works in a program? I don't understand.
John: I don't understand why you say "Horizontally: concat works fine". When I enter "concat (M1,M2)", it returns the list {M1,M2}, not the augmentation of M2 to M1. Cyrille: Thank you for the construction / deconstruction info. I had no idea you could reference e.g. M1(r), M1(-c). Could you give an explicit example showing how you would place a vector using M(r,c)? I understand how you would use M(r) or M(-c) but not M(r,c). There is a problem, Cyrille, with the "Makelist; replace; replace" augmentation method you suggested, apparently an HP Prime bug. I've attached a screenshot demonstrating the problem. "Replace(M3,{1,1},M1)" works fine but then "Replace(M3{1,4},M2)" zeroes the left half of M3 in the process of placing M2 in the right half. On the main subject, augmenting two matrices in a program, here is code that actually works (preceded by R:=rowDim(M1);C:=colDim(M1);): As Helge suggested: M3:=list2mat(concat(mat2list(M1),mat2list(M2)),C);//vertical M3:=trn(list2mat(concat(mat2list(trn(M1)),mat2list(trn(M2))),R)); //horizontal or using Makemat: M3:=makemat(piecewise(I<=R,M1(I,J),I>R,M2(I-R,J)),R+rowDim(M2),C);//vert M3:=makemat(piecewise(J<=C,M1(I,J),J>C,M2(I,J-C)),R,C+colDim(M2));//horiz For me, these are all joylessly convoluted. Still wishing for something simpler. jfs |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)