フィルターのクリア

Writing a quadratic equation program to satisfy a solution. I am very confused help please.

2 ビュー (過去 30 日間)
Reelz
Reelz 2012 年 4 月 14 日
I am trying to write a program in which two solutions, v and w, of the quadratic equation q(x) = ax^2 + bx +c = 0, that satisfies vw = c/a. I want this program to numerically solve such equations given a, b and c. The larger (abs solution) v using this quadratic formula, and the smaller w using w = c/(av), and of course having a provision for a = 0. I want my output to be a vector of solutions showing how many solutions exist. This relatively simple exercise is killing me because I cannot figure it out. Help greatly appreciated with explanation.
  2 件のコメント
Reelz
Reelz 2012 年 4 月 14 日
Here is what I have, I am confused on how to set up my parameters correctly.
function [x,y] = rqe2(a,b,c)
x = (-b + sqrt(b^2 - 4 * a * c))/(2*a);
y = (-b - sqrt(b^2 - 4 * a * c))/(2*a);
if vw = c/a;
w = c/(av);
v > w;
a==0;
end
Reelz
Reelz 2012 年 4 月 14 日
I get an error when trying to run that says this:
Error: File: rqe2.m Line: 4 Column: 7
The expression to the left of the equals sign is not a valid target for an assignment.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 4 月 15 日
if vw = c/a;
is not a valid statement. The comparison operator is == rather than =
  6 件のコメント
Reelz
Reelz 2012 年 4 月 17 日
>> rqe2(5,9,15)
??? Error: File: rqe2.m Line: 4 Column: 7
The expression to the left of the equals sign is not a valid target for an
assignment.
Still receiving error!
Walter Roberson
Walter Roberson 2012 年 4 月 17 日
Please show your current code.

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

カテゴリ

Help Center および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by