MATLAB: Find a column vector such that the determinant of a matrix A is non-zero

findMATLABmatrix

Let H1 = Span_IR{(1; 0; 0; 0; 0; 0); (0; 1; 0; 0; 0; 0)}
H2 = Span_IR{(0; 0; 1; 0; 0; 0); (0; 0; 0; 1; 0; 0)}
H3 = Span_IR{(0; 0; 0; 0; 1; 0); (0; 0; 0; 0; 0; 1)}
H4 = Span_IR{(1; 0; 1; 0; 1; 0); (0; 1; 0; 1; 0; 1)}
i want to find two vectors (x1,x2,x3,x4,x5,x6) and (y1,y2,y3,y4,y5,y6) such that
H= span{(x1,x2,x3,x4,x5,x6) ,(y1,y2,y3,y4,y5,y6)} and
SpanR(Hi ;Hj ;H ) = R^6. where i,j in {1,2,3,4}.
so we have six matrixs that must not be zero . every matrix is composed by the two vector (x1,x2,x3,x4,x5,x6) and (y1,y2,y3,y4,y5,y6) and 4 vectors among the eight vectors of H1, H2 H3 and H4.
for example
A1 = [1 0 0 0 x1 y1;0 1 0 0 x2 y2;0 0 1 0 x3 y3;0 0 0 1 x4 y4;0 0 0 0 x5 y5;0 0 0 0 x6 y6] then DET(A) must be non zero.
hope this is clear.

Best Answer

A8 = [1 0 0 0 0 0 1 0;
0 1 0 0 0 0 0 1;
0 0 1 0 0 0 1 0;
0 0 0 1 0 0 0 1 ;
0 0 0 0 1 0 1 0;
0 0 0 0 0 1 0 1]
ij=nchoosek(1:4,2);
binaryflag = true; % put it TRUE if you want X and Y binary, even if it's not stated in the question
% This method is O(1) for binaryflag = false
while true
if binaryflag
H = rand(6,2) > 0.5;
else
H = randn(6,2);
H = H ./ sqrt(sum(H.^2,1));
end
for k=1:size(ij,1)
i=ij(k,1);
j=ij(k,2);
Hi = A8(:,2*i+(-1:0));
Hj = A8(:,2*j+(-1:0));
A = [Hi,Hj,H];
d = eigs(A,1,'smallestabs');
OK = abs(d) >= 1e-12;
if ~OK
% for binaryflag=FALSE, likely never get here !
% fprintf('detect possible singularity\n');
break
end
end
if OK
% for binaryflag=FALSE likely get here the first iteration
break;
end
end
X = H(:,1)
Y = H(:,2)