Removing rows and columns from MATLAB matrix quickly

后端 未结 2 1594
难免孤独
难免孤独 2020-12-20 11:36

Is there a fast way to remove rows and columns from a large matrix in MATLAB?

I have a very large (square) distance matrix, that I want to remove a number of rows/co

2条回答
  •  无人及你
    2020-12-20 12:25

    I think it will depend on your usage, but I have two ideas:

    1. Make it a sparse matrix. The more you're removing the better this option will probably be.
    2. Why do you need to remove the values? Could you maybe do:

    
    A = D(randsample(s,2), randsample(s,2));
    clear D;
    % Use A
    

提交回复
热议问题