Rank Nullity

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

% For Function

function [Rank,Nullity,Rowspace,Nullspace] = ranknullity(A)


refA = rref(A)
[m, n] = size(A)
b(1:n) = 0
for i=1:m
for j=i:n
if refA(i,j)==1
b(j)=j
break
end
end
end
Rank = rank(A)
Nullity = size(null(A, 'r'),2)
Rowspace = double(colspace(sym(A.')).')
Nullspace = refA(:, find(~b))
end

% Call Function
A = magic(4)
[Rank,Nullity,Rowspace,Nullspace] = ranknullity(A)

You might also like