Creating an Indicator Vector

11 Ansichten (letzte 30 Tage)
Alex Wieseler
Alex Wieseler am 16 Sep. 2020
Kommentiert: Alex Wieseler am 16 Sep. 2020
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

Antworten (1)

madhan ravi
madhan ravi am 16 Sep. 2020
indvector(pivot) = 1

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by