finding the roots of a multivariable equation
조회 수: 8 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!