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$
3
$\begingroup$

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

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

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.