plotting root of Polynomial Equation
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ammar Ahmed
il 20 Giu 2019
Commentato: Star Strider
il 21 Giu 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 Commento
John D'Errico
il 20 Giu 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.
Risposta accettata
Star Strider
il 20 Giu 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Polynomials in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!