Solving a Cubic Equation

I am new to Matlab and I can't work out how to solve this cubic equation.
(Q/Qw)^3-(Q/Qw)-(1/F^3)=0.
I have Qw and F both as 1x108 matrices and I am trying to solve this equation for Q.
I would like to be able to see the answers in Q as numbers as to extract them so Q/Qw against f could be plotted.
Any help would be much appreciated.

 Akzeptierte Antwort

Nathaniel
Nathaniel am 5 Nov. 2012

0 Stimmen

The built-in function roots is what you're looking for.

4 Kommentare

Matthew
Matthew am 6 Nov. 2012
Thanks for your answer but I still seem to be experiencing difficulties. I keep gettin this error
Error: The expression to the left of the equals sign is not a valid target for an assignment.
I have Qw and F both as 1x108 matrices. Is the problem in here? Can this be fixed?
Thanks
Matt J
Matt J am 6 Nov. 2012
Bearbeitet: Matt J am 6 Nov. 2012
It means the expression on the LHS of the line that gave you the error is a non-variable or something, for example:
>> 1=x
1=x
|
Error: The expression to the left of the equals sign is not a valid target for an
assignment.
I'm sort of wondering if you've issued a command like
(Q/Qw)=roots(...)
Matthew
Matthew am 6 Nov. 2012
I don't think I did that, this is what i did.
I have Qw and F both as 1x108 matrices.
roots((Q/Qw)^3-(Q/Qw)-(1/F^3)=0)
|
Error: The expression to the left of the equals sign is not a valid target for an
assignment.
Nathaniel
Nathaniel am 12 Nov. 2012
So hopefully by now, you have read the documentation and learned the proper syntax.
In the interest of not leaving this thread hanging, this is the syntax for your equation. If you have 108 of them, then you'll need to put it in a loop.
Q = roots([1/Qw 0 -1/Qw -1/F^3]);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by