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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by