Double for Loop to find root of polynomial

조회 수: 2 (최근 30일)
Alexander Kimbley
Alexander Kimbley 2019년 10월 30일
댓글: Alexander Kimbley 2019년 10월 31일
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.

채택된 답변

John D'Errico
John D'Errico 2019년 10월 30일
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
Alexander Kimbley
Alexander Kimbley 2019년 10월 31일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by