plotting root of Polynomial Equation

3 views (last 30 days)
hi , I'm trying to plot a root of polynomial equation that have to set of complex solution as 1 X 4 cell
any suggestion how to plot the data obtianed
p = [0.20,0.23,0.25,0.27]';
er1 = (1+1.8*10^14*i);
er2 = (2.5+2.5*10^-3*i);
pol = [2+p*0, (-2+3*p)*er2 + (1-3*p)*er1, -er1*er2+p*0];
EQ2 = arrayfun(@(i) roots(pol(i,:)),1:numel(p),'uni',0);
plot(p,EQ2)
  1 Comment
John D'Errico
John D'Errico on 20 Jun 2019
Note that the roots will not necessarily be in any special order. So when you do plot them in sequence with p, things may jump around.
One idea would be to convert the sequence of polynomials to a sequence of 4x4 matrices. This is called the companion matrix. you can find that in the function compan.
help compan
Then use my eigenshuffle utility (found on the file exchange) to resort the eigenvalues to be in a consistent order.
Finally, do as Star suggests, and plot the real part on the x axis, and the imaginary part on the y axis.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 20 Jun 2019
You need to extract the double arrays from the cells in ‘EQ’:
plot(p,real([EQ2{:}]),'-', p,imag([EQ2{:}]),'--')
The cell2mat function is also an option.

More Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!