1

Well, the title says it all. I am looking for a way to add rows or columns to an object created with

mm = math.matrix([[0, 1], [2, 3], [4, 5]]);
// can we do something like 
mm.push([0,1]);

I refer to the mathjs library here.

Matt Bannert
  • 27,631
  • 38
  • 141
  • 207

2 Answers2

2

i also checked their docs..they don't have direct push or any other functionality to achieve this.we have try our self in different manner to achieve that functionality .

1) convert to array and pass to matrix again

2) or add ur own method for matrix object

 math.push=function(e){
 // ur own code to implement the push  
 }
yugi
  • 834
  • 1
  • 15
  • 28
1

There is no push like function available. You can of course open a request for this in the issues section of the project.

The solution that comes closest is using the concat function:

mm = math.matrix([[0, 1], [2, 3], [4, 5]]);
mm = math.concat(mm, [[0,1]], 0);
// mm now contains: [[0, 1], [2, 3], [4, 5], [0, 1]]

The last number in the concat function specifies the dimension where to add the new data.

Jos de Jong
  • 6,602
  • 3
  • 38
  • 58