How to define a variable without using syms ?

조회 수: 20 (최근 30일)
Manchikatla Laxmi Prasanna
Manchikatla Laxmi Prasanna 2021년 1월 5일
편집: John D'Errico 2021년 1월 5일
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에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by