I want to create a square NxN matrix orthogonal, with the constraint that the first column is a column vector of k*ones(N,1), where k is a constant at choice. Is there any procedure?
I.e.
A= [k * *;k * *;k * *]
is a 3x3 matrix, where the first column is a vector k*ones(3,1), and the other two vectors have to be created in such a way the matrix is orthogonal
Maybe this should be posted on Math.StackEchange where equations can be typed properly if you want a proper theoretical explanation. But if just want the code...
First, if N
is the dimension of your matrix, this constrains the value of k
to:
k=sqrt(1/N);
A(1,:) = k*ones(1,N);
Then, the second row can be constructed with:
A(2,:) = sqrt(0.5)*[1,-1,zeros(1,N-2)];
This creates a simple vector orthogonal to the first.
The third line can be computed with:
aux = [1,1,-2,zeros(1,N-3)];
A(3,:) = aux/norm(aux);
The fourth:
aux = [1,1,1,-3,zeros(1,N-4)];
A(4,:) = aux/norm(aux);
And so on.
In short:
A=zeros(N);
k=sqrt(1/N);
A(1,:) = k*ones(1,N);
for i=2:N
aux = [ones(1,i-1),-(i-1),zeros(1,N-i)];
A(i,:) = aux/norm(aux);
end