How to define a variable without using syms ?

44 次查看(过去 30 天)
I am trying to find out eigen values of a matrix without using builtin command.in this I have to do det(A-lambda*I)==0
for this I have to declare a variable without intializing any value to it.
how can I intialize a variable by not assigning any value to it without using SYMBOLIC MATH TOOLBOX?
can anyone help me to do this
thanks in advance
  2 个评论
KSSV
KSSV 2021-1-5
I don't think this is possible without defining symbolic x. What problem you have to define sym x?
John D'Errico
John D'Errico 2021-1-5
编辑:John D'Errico 2021-1-5
Of course you can use a variable that you have not defined as symbolic. Define a FUNCTION that uses an unknown variable. You can then evaluate said function as you please, and this is what root finders excell at doing.

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2021-1-5
编辑:John D'Errico 2021-1-5
fun = @(lambda) det(A - lambda*eye(size(A)));
fun is a function of the unknown variable lambda. It is a function handle. It has A built into the function handle workspace, so any tool that gets passed the function fun can use it.
Now, you can use a tool like fzero on fun, solving for values of lambda that make fun equal to zero. Note that fzero only returns ONE solution for any time it is called, and you may get different solutions based on different starting values or starting intervals. So you will need to use fzero intelligently.
For example,
A = magic(3)
A =
8 1 6
3 5 7
4 9 2
fun = @(lambda) det(A - lambda*eye(size(A)));
Now you can evaluate fun.
fun(2.5)
ans =
-221.875
Again, what remains for you to do is to understand how to solve the problem, how to pass fun to a root finder, like fzero or fsolve, and to do that multiple times. Or perhaps you will be forced to use your own root finding tool, written for some past assignment.
One hopes that your instructor has not given you a matrix with replicated eigenvalues. That would be a nasty trick to really confuse a student, but then students are there to be confused in the eyes of some people. :)

类别

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