1
$\begingroup$

I'm having a hard time in trying to get rid of linearly dependent columns of a matrix on matlab. I was trying to run this code

for i=2:22
    if rank(D(:,1:i))==i-1
        D(:,i)=[];
    end
end 

for a 30x30 matrix with rank 22, which means that I have to get rid of 8 linearly dependent columns. In this code I am just getting rid of the first ld column and the the following one that is not ld. Does anyone know how to do that? Thanks!

$\endgroup$

1 Answer 1

4
$\begingroup$

If you do not mind using matlab built-in functions:

[~,colind] = rref(A);
B = A(:, colind); 
$\endgroup$
1
  • 1
    $\begingroup$ Thank you so much.It worked!!! $\endgroup$
    – Lucas
    Mar 7, 2015 at 4:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .