Trying to find the value of z for any value of k

2 ビュー (過去 30 日間)
Saim
Saim 2022 年 10 月 5 日
編集済み: KSSV 2022 年 10 月 5 日
I have the following code:
syms k
A = [1 -((k^2)+3) ((k^2)+3) -1];
Y = roots(A)
which returns:
Y = 1
k^2/2 - (k*(k^2 + 4)^(1/2))/2 + 1
(k*(k^2 + 4)^(1/2))/2 + k^2/2 + 1
now, I have:
Z = Y(3,1)*Y(2,1)
which returns:
Z =
(k^2/2 - (k*(k^2 + 4)^(1/2))/2 + 1)*((k*(k^2 + 4)^(1/2))/2 + k^2/2 + 1)
Now, I want to test multiple values of k in the function Z, how do I do this?

採用された回答

KSSV
KSSV 2022 年 10 月 5 日
Read about subs. Using this, you can substitute the required value of k. You need to convert the result/ syms call into a number using double.
double(subs(Z,k,1))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by