Creating an Indicator Vector
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Antworten (1)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!