matrix retrieving given certain determinant
显示 更早的评论
dear all i want to retrieve matrix 3x3 with given determinant thanks
回答(2 个)
determinant = -30;
diagonal = abs(determinant)^(1/3);
A = zeros(3);
A(1,1) = diagonal;
A(2,2) = diagonal;
A(3,3) = sign(determinant)*diagonal;
det(A)
You want to generate a random matrix with a known determinant?
n = 7; % The size of the matrix
Dtarget = 12; % My target determinant
A = randn(n);
DA = det(A);
A = A*sign(DA)*nthroot(Dtarget/abs(DA),n)
Was I successful?
det(A)
Do you want another solution?
n = 5;
A = rand(n);
Dtarget = 17; % My target determinant
[L,U] = lu(A);
L(1,:) = L(1,:)*sign(prod(diag(U)));
U(1:n+1:end) = nthroot(Dtarget,n);
A = L*U
det(A)
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!