I want to calculate roots of a polynomial whose coefficients are functions of x where x assume values between an interval

조회 수: 2 (최근 30일)
Let x =[0:1:10]; polynomial = [ 1 sin(x) x.^3 x]; let v1,v2 and v3 be the three roots of given polynomial in v whose coefficients are functions of x. I want to plot a graph between v1 and x.
  댓글 수: 6
ASHA RANI
ASHA RANI 2017년 10월 21일
편집: Matt J 2017년 10월 21일
> x = [0:pi/18:pi/6]
x =
0 0.1745 0.3491 0.5236
>> p = [1 sin(x) x.^3 x];
>> r = roots(p)
r =
0.8999 + 0.3217i
0.8999 - 0.3217i
0.6749 + 0.8031i
0.6749 - 0.8031i
0.2643 + 0.9220i
0.2643 - 0.9220i
-0.3081 + 0.8491i
-0.3081 - 0.8491i
-0.8635 + 0.2723i
-0.8635 - 0.2723i
-0.6675 + 0.6335i
-0.6675 - 0.6335i
in this ans of r, which one is represented v1 corresponding to pi/18?
John D'Errico
John D'Errico 2017년 10월 21일
So why did you set x=pi/18?
You were asked to solve this problem for x varying from 0 to 10, NOT just at one value of x.
If the polynomial has three roots, what does v1 versus v2 and v3 mean? Roots need not be provided in any specific order. So how are you supposed to choose v1?

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

채택된 답변

Matt J
Matt J 2017년 10월 21일
편집: Matt J 2017년 10월 21일
You cannot use ROOTS on multiple polynomials at a time. You will have to use a loop over x(i),
for i=1:numel(x)
p =[1 sin(x(i)) x(i).^3 x(i)];
r{i}=roots(p);
%More code...
end
  댓글 수: 3
ASHA RANI
ASHA RANI 2017년 10월 21일
thank you,sir I am sending my original problem in which I want to plot between v1 and corresponding x. please help it

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by