Effacer les filtres
Effacer les filtres

plotting root of Polynomial Equation

2 vues (au cours des 30 derniers jours)
Ammar Ahmed
Ammar Ahmed le 20 Juin 2019
Commenté : Star Strider le 21 Juin 2019
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 commentaire
John D'Errico
John D'Errico le 20 Juin 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.

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 20 Juin 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.
  2 commentaires
Ammar Ahmed
Ammar Ahmed le 21 Juin 2019
thanks it working perfectly fine
Star Strider
Star Strider le 21 Juin 2019
As always, my pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by