finding the roots of a multivariable equation
18 次查看(过去 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
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
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!