How to solve quadratic equation which includes a vector?

13 ビュー (過去 30 日間)
Lu Da Silva
Lu Da Silva 2020 年 11 月 17 日
コメント済み: Lu Da Silva 2020 年 11 月 18 日
Hi,
I have the following equation: V1^2 - V1*V2 - Q*Z = 0
V1 is what I need to find
V2 is a known constant
Q is a known vector with complex values
Z is a known constant
This is what I've tried:
syms V1
eq = V1^2 - V1*V2 - Q*Z;
result = roots(eq);
But I get the result "Empty sym: 0-by-1"

採用された回答

Setsuna Yuuki.
Setsuna Yuuki. 2020 年 11 月 17 日
編集済み: Setsuna Yuuki. 2020 年 11 月 17 日
You can try with solve:
syms V1
eq = V1^2 - V1*V2 - Q*Z;
result = solve(eq,V1);
  6 件のコメント
Lu Da Silva
Lu Da Silva 2020 年 11 月 18 日
The former loop worked, yet I only get one result: the positive and negative result of the last value of my Q-vector... Shouldn't I get a vector/matrix as a result? Maybe roots isn't the right function for this case...? For some reason it's not saving all the values yet just the last one
Lu Da Silva
Lu Da Silva 2020 年 11 月 18 日
Figured it out; it's
for i = 1:length(Q)
eq2 = [1 -V2 -Q(i)*Z];
result(i,:) = roots(eq2)
end
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by