Re: Package to 'graft' Lists onto Matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg87742] Re: [mg87667] Package to 'graft' Lists onto Matrices
- From: "W_Craig Carter" <ccarter at mit.edu>
- Date: Wed, 16 Apr 2008 05:06:34 -0400 (EDT)
- References: <200804150952.FAA25046@smc.vnet.net>
Hello, You might try these: mat = RandomInteger[{0, 10}, {5, 7}]; mat // MatrixForm AddRow[mat_?MatrixQ, row_List] := Join[mat, {row}] AddRow[mat, {a, b, c, d, e, f, g}] // MatrixForm AddColumn[mat_?MatrixQ, column_List] := Transpose[Join[Transpose[mat], {column}]] AddColumn[mat, {a, b, c, d, e}] // MatrixForm No checking here or matching dimensions, but that could be built in easily. > > It seems a little daft that that you need to use MapThread and Append to simply graft a row onto an existing matrix! > -- W. Craig Carter
- References:
- Package to 'graft' Lists onto Matrices
- From: robert prince-wright <robertprincewright@yahoo.com>
- Package to 'graft' Lists onto Matrices