Solve for variable x in a matrix with matlab

5 次查看(过去 30 天)
I want to use matlab to solve for x in this matrix:
A= [ 1 x 1 0 0 0 ;
0 1 x 1 0 0 ;
0 0 1 x 1 1 ;
0 0 0 1 x 1 ;
1 0 0 0 1 x ]
  2 个评论
BuckeyeLink
BuckeyeLink 2015-11-5
I want matlab to solve for the determinant when the matrix is equal to zero.
John D'Errico
John D'Errico 2015-11-6
Sigh. solve for the determinant when the matrix is equal to zero? Again. no mathematical meaning in that comment.
You can have a determinant of a matrix, but not a non-square matrix.
You cannot have the determinant of an equality, so asking for the determinant when the matrix is equal to zero is meaningless in terms of mathematics.
Maybe you meant to solve for x, such that the determinant of A is zero. But that too is meaningless, since A is non-square.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2015-11-5
It looks to me that any arbitrary value would work, if that’s all the information you have.
  2 个评论
BuckeyeLink
BuckeyeLink 2015-11-5
Sorry, I left that out. The matrix is equal to zero.
The specific instructions are: Solve the secular equation using Matlab.
I understand how to do it by hand, but I'm not sure how to code Matlab to achieve that result.
Star Strider
Star Strider 2015-11-5
编辑:Star Strider 2015-11-5
I had to look up ‘secular equation’. It seems it’s the characteristic polynomial of a square matrix (eigenvalues), but your matrix isn’t square.
I would put zeros in place of the ‘x’ values and use the eig function. See also Eigenvalues and Singlular Values for a comprehensive list of applicable functions.
EDIT — Consider using the Symbolic Math Toolbox.

请先登录,再进行评论。

更多回答(1 个)

John D'Errico
John D'Errico 2015-11-5
编辑:John D'Errico 2015-11-6
Solve what? A variable is just that, an unknown number. A matrix is just a collection of numbers. You have posed no equality statement, so there is no solution to be found.
Had you given some relationship that involves A. For example, solve for x, such that A is singular, or that A has a minimum norm, or that norm(A*ones(5,1)) is minimized, or any of a variety of equality statements, then we could talk about a solution. The solution might not be unique.
But as your question is posed, it is a meaningless question. There is no "solution".
Edit:
I'll assume that the real question is to solve for x, SUCH THAT the determinant, det(A(x))==0
I'll also assume that A is a square matrix, so I am forced to arbitrarily modify A so that can happen.
syms x
A= [ 1 x 1 0 0 0 ;
0 1 x 1 0 0 ;
0 0 1 x 1 1 ;
0 0 0 1 x 1 ;
1 0 0 0 1 x ;
0 1 0 0 0 1];
A is now a square matrix.
p = det(A)
p =
2*x^4 - 6*x^2 + 4
solve(p == 0)
ans =
-1
1
2^(1 / 2)
-2^(1 / 2)
Finally, IF by secular equation, you intend to solve for the roots of the characteristic polynomial, in theory, this would be done as follows:
syms lambda
P = det(A - lambda*eye(6))
P =
lambda^6 - 6*lambda^5 + 15*lambda^4 - lambda^3*x - 22*lambda^3 - 6*lambda^2*x^2 + 3*lambda^2*x + 21*lambda^2 - 2*lambda*x^4 + 12*lambda*x^2 - 3*lambda*x - 12*lambda + 2*x^4 - 6*x^2 + 4
solve(P == 0,lambda)
ans =
root(z^6 - 6*z^5 + 15*z^4 - z^3*(x + 22) + z^2*(3*x - 6*x^2 + 21) - z*(3*x - 12*x^2 + 2*x^4 + 12) - 6*x^2 + 2*x^4 + 4, z, 1)
root(z^6 - 6*z^5 + 15*z^4 - z^3*(x + 22) + z^2*(3*x - 6*x^2 + 21) - z*(3*x - 12*x^2 + 2*x^4 + 12) - 6*x^2 + 2*x^4 + 4, z, 2)
root(z^6 - 6*z^5 + 15*z^4 - z^3*(x + 22) + z^2*(3*x - 6*x^2 + 21) - z*(3*x - 12*x^2 + 2*x^4 + 12) - 6*x^2 + 2*x^4 + 4, z, 3)
root(z^6 - 6*z^5 + 15*z^4 - z^3*(x + 22) + z^2*(3*x - 6*x^2 + 21) - z*(3*x - 12*x^2 + 2*x^4 + 12) - 6*x^2 + 2*x^4 + 4, z, 4)
root(z^6 - 6*z^5 + 15*z^4 - z^3*(x + 22) + z^2*(3*x - 6*x^2 + 21) - z*(3*x - 12*x^2 + 2*x^4 + 12) - 6*x^2 + 2*x^4 + 4, z, 5)
root(z^6 - 6*z^5 + 15*z^4 - z^3*(x + 22) + z^2*(3*x - 6*x^2 + 21) - z*(3*x - 12*x^2 + 2*x^4 + 12) - 6*x^2 + 2*x^4 + 4, z, 6)
Of course, it must fail, since this is a polynomial of order higher than 4, with non-constant coefficients. So we cannot solve it.
You need to explain your problem CLEARLY.
  2 个评论
BuckeyeLink
BuckeyeLink 2015-11-5
Sorry, I left that out. The matrix is equal to zero.
The specific instructions are: Solve the secular equation using Matlab.
I understand how to do it by hand, but I'm not sure how to code Matlab to achieve that result.
John D'Errico
John D'Errico 2015-11-6
Still meaningless. The matrix is not square. eigenvalues are undefined for non-square matrices.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by