finding the roots of a multivariable equation

6 ビュー (過去 30 日間)
Tomás
Tomás 2019 年 10 月 1 日
コメント済み: David Hill 2019 年 10 月 1 日
how would i go about plotting the roots (y) of a multivariable equation:
ysin(2x) + sin(2yx) = 0
with x values of pi/2 to pi?
i'm looking for the smallest non-zero, non-negative root
this is what i have so far:
x=linspace(pi/2,pi)
for z=(1:100)
eqn= @(y) y*sin(2*x(z)) + sin(2*y*x(z))
yRoots = fzero(eqn,0)
end
my yRoots is just an array of 0's in this case. for example, for x=pi/2 , the root i'm actually looking for is 1. how do i get matlab to ignore the 0 root and just give me the first positive root?
  1 件のコメント
David Hill
David Hill 2019 年 10 月 1 日
You may want to try plotting first. You will need to change the search interval to find the root you want.
y=-20:.1:20;
z=arrayfun(@(x) y*sin(2*x) + sin(2*y*x),pi/2:.01:pi,'UniformOutput',false);
plot(y,z{20});%choose whatever x value you want to look at, you could plot several of them using a loop
to find the root, select the interval you are interested in
x=pi/2;
eqn = @(y) y*sin(2*x) + sin(2*y*x);
yRoot = fzero(eqn,[.9 1.1]);% produces root of 1
yRoot = fzero(eqn,[1.9 2.1]);%produces root of 2

サインインしてコメントする。

採用された回答

Matt J
Matt J 2019 年 10 月 1 日
Something like this, perhaps:
x=linspace(pi/2,pi);
for z=(1:100)
eqn= @(y) sinc(2*x(z)) + sinc(2*y*x(z));
yRoots(z) = abs( fzero(eqn,1e-8) )
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by