0
$\begingroup$

I have implemented this dropOperator from dropOperator from stackexchange and works fine on a single Matrix. But now I have a Matrix of a Matrix and want to drop some rows or columns (in the pic below f.e row 2,5,7) of Matrixes of that Matrix-Matrix. It seems that this could not be done with that dropOperator described in the above link.

Can anyone help please? Thanks!

This should work:

enter image description here

$\endgroup$
0
1
$\begingroup$

It is not clear why you need special functions to do what you want instead of using Drop. I think you should provide a minimum working example of your starting "matrix of matrix" and what you want the end result to be.

In any case try this:

m = Array[FromDigits[{##}] &, {3, 3, 4}]

Drop[m, {2}] // MatrixForm

Drop[m, None, {2}] // MatrixForm

Edit

Okay after I posted I've just read your revised Q.

Here is a starting point that seems to be a similar form to yours:

m = Array[FromDigits[{##}] &, {9, 4, 6, 2}];
MatrixForm[m]

enter image description here

So to drop rows 2, 5, and 7:

Part[m, {1, 3, 4, 6, 8, 9}] // MatrixForm

enter image description here

unevenDropRow[m_, pos_] := Part[m, Complement[Range[Length[m]], pos]]
unevenDropCol[m_, pos_] := Part[m, All, Complement[Range[Length[m[[1]]]], pos]]

Note that the above are specific for the problem you have raised. They may need to be expanded/generalised depending on how typical this is of your usage. You can combine the row and column drops into one:

unevenDrop[m_, rowpos_, colpos_] := Part[m, Complement[Range[Length[m]], rowpos], 
  Complement[Range[Length[m[[1]]]], colpos]]

unevenDrop[m, {2, 5, 7}, {2, 3}] // MatrixForm
$\endgroup$
1
  • $\begingroup$ Thanks a Lot, that was it I was looking for! $\endgroup$ Nov 24 '14 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.