roots

6 Ansichten (letzte 30 Tage)
Nasir Qazi
Nasir Qazi am 25 Feb. 2012
Bearbeitet: Matt J am 25 Okt. 2013
how to find a roots of a cubic equation in matlab?

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 25 Feb. 2012
please read about function roots
or use function solve from Symbolic Math Toolbox
eg
use roots
%polynomial x^3-6*x^2-50*x-4
p = [1 -6 -50 -4]
out = roots(p)
use solve and Symbolic Math Toolbox
syms x
out2 = solve(x^3-6*x^2-50*x-4)
vpa(out2,6)
on Nasir comment
out = zeros(3,...);
for j1 = 1:....
B = ...
A = ...
out(:,j1) = roots([1, B-1, A-3*B^2, A*B-B^2-B^3]);
end
  5 Kommentare
Nasir Qazi
Nasir Qazi am 27 Feb. 2012
I have a condition of trail and error which will repeat the process of roots find after a condition of error checking , but after 10 iteration it give me a error , root input cannot be inf or nan , where exactly do I have a fault in the coding ... ?
Walter Roberson
Walter Roberson am 27 Feb. 2012
I think we would need to see the code.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by