Borrar filtros
Borrar filtros

plotting root of Polynomial Equation

2 visualizaciones (últimos 30 días)
Ammar Ahmed
Ammar Ahmed el 20 de Jun. de 2019
Comentada: Star Strider el 21 de Jun. de 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 comentario
John D'Errico
John D'Errico el 20 de Jun. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 20 de Jun. de 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 comentarios
Ammar Ahmed
Ammar Ahmed el 21 de Jun. de 2019
thanks it working perfectly fine
Star Strider
Star Strider el 21 de Jun. de 2019
As always, my pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by