finding the roots of a multivariable equation

31 Ansichten (letzte 30 Tage)
Tomás
Tomás am 1 Okt. 2019
Kommentiert: David Hill am 1 Okt. 2019
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 Kommentar
David Hill
David Hill am 1 Okt. 2019
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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 1 Okt. 2019
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

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by