How to define a variable without using syms ?

44 ビュー (過去 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 Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by