Creating an Indicator Vector

조회 수: 9 (최근 30일)
Alex Wieseler
Alex Wieseler 2020년 9월 16일
댓글: Alex Wieseler 2020년 9월 16일
So I am wondering how I create an indicator vector using pivot columns that I stored. Essentially I have created a varible, 'pivot' that stores the columns,c, where there is a pivot entry at.
Example: If the matrix is [1 0 0 0 0; 0 0 1 0 0; 0 0 0 0 1] pivot = [1,3,5]
Now since I found those pivots I want to create an indicating vector using these column values... so if I have a vector called indvect = zeros(1,n), I want to add 1 to the columns of that indvector where there is a pivot...
Example: pivot =[1,3,5] indvector = zeros(1,n)
I want the indvector to be [1 0 1 0 1]
Any help is much appreciated
My code is below
function B= NullBasis(A)
indvector= zeros
thresh = 1e-6
[m n]= size(A);
r=0;
A=rref(A)
for r=1:1:m
r
c=1
if A(r,:)* A(r,:)'> thresh
while abs(A(r,c))< thresh && c<n
c=c+1;
end
end
pivot(r) = c
end
end

답변 (1개)

madhan ravi
madhan ravi 2020년 9월 16일
indvector(pivot) = 1

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by