finding the roots of a multivariable equation

41 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by