Double for Loop to find root of polynomial

2 visualizaciones (últimos 30 días)
Alexander Kimbley
Alexander Kimbley el 30 de Oct. de 2019
Comentada: Alexander Kimbley el 31 de Oct. de 2019
Hi,
I'm trying to code a double for loop for the variables M and L, allowing me to find the roots of the polynomial at each point for 0<M, L<1. I'm very new to MATLAB and can't really get anything useful.
Thanks.

Respuesta aceptada

John D'Errico
John D'Errico el 30 de Oct. de 2019
lambda=2;
Quadratic_For_Omega_Squared=@(L,M)[1,-(L^2 +2 * M^2 +1 -lambda), +M^2 * (L^2 +M^2 -lambda)];
L=1:-0.1:0;
M=1:-0.1:0;
R = zeros(numel(L),numel(M),2);
for k1 = 1:numel(L);
for k2 = 1:numel(M);
p = Quadratic_For_Omega_Squared(L(k1),M(k2));
R(k1,k2,:) = roots(p);
end
end
  1 comentario
Alexander Kimbley
Alexander Kimbley el 31 de Oct. de 2019
Thanks,
is there anyway I could extend this question for the code to present a graph in (L,M) space where each point is a certain colour depending on how many roots at that point are postive, i.e. 0,1 or 2.
Thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by