답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 2월 25일

0 개 추천

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

Nasir Qazi
Nasir Qazi 2012년 2월 25일
if I have equation like this
Z^3 +(B-1)Z^2 +(A-3B^2)Z -(AB-B^2-B^3)=0
where the values of A & B are varies in iteration .
in that case how can I calculate the Roots ?
Walter Roberson
Walter Roberson 2012년 2월 25일
Careful, there would be three roots for each cubic, so you would not be able to store the output of roots() in to a single array location out(j1)
Andrei Bobrov
Andrei Bobrov 2012년 2월 25일
Thank you Walter! Corrected.
Nasir Qazi
Nasir Qazi 2012년 2월 27일
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 2012년 2월 27일
I think we would need to see the code.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

질문:

2012년 2월 25일

편집:

2013년 10월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by