generate orthogonal matrix function
조회 수: 22 (최근 30일)
이전 댓글 표시
Hi there,
Assume I have two square matrix A and B with the same size, I want to find a matrix that orthogonal to A but non-orthogonal to B, i.e., AC=0 and BC≠0, where C is the matrix I want.
Is there any function can generate it? I know null(A) can generate the orthogonal matrix of A, but I want to ensure it is non-orthogonal to B meanwhile.
Thanks,
댓글 수: 1
David Goodmanson
2023년 9월 8일
편집: David Goodmanson
2023년 9월 8일
Hi MN,
for this to work there will have to be restrictions on A and B. For example, A cannot be of full rank, because if it is, then it has and inverse, in which case AC = 0 --> C=0. So suppose A is not of full rank. Then B must have at least one row that is linearly independent of the rows of A, otherwise AC = 0 --> BC = 0.
답변 (1개)
Bruno Luong
2023년 9월 8일
편집: Bruno Luong
2023년 9월 8일
I claim this returns the solution C that is orthogonal to A but not to B (meaning not to all of columns of B)
A = rand(5,4)*rand(4,5);
B = rand(5,4)*rand(4,5);
AO = null(A.');
ABO = null([A B].');
v = null(ABO'*AO);
if isempty(v)
fprintf('solution does not exist\n')
return
end
v1 = v(:,1);
[Q,~,~] = qr([2*v1, eye(size(AO,2))]);
C = AO*Q
% Check
norm( A'*C, 'fro')
norm( B'*C, 'fro')
댓글 수: 3
Bruno Luong
2023년 9월 8일
Thanks I fix it just a small detail, my algo supposes to work with non-square and square matrices
Bruno Luong
2023년 9월 8일
To get the orthogonal of rows A, B, change the first two statements
A = rand(5,4)*rand(4,5);
B = rand(5,4)*rand(4,5);
AO = null(A); % change
ABO = null([A; B]); % change
v = null(ABO'*AO);
if isempty(v)
fprintf('solution does not exist\n')
return
end
v1 = v(:,1);
[Q,~,~] = qr([2*v1, eye(size(AO,2))]);
C = AO*Q
% Check
norm( A*C, 'fro')
norm( B*C, 'fro')
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Math에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!