Solving non linear equation with a range in MATLAB (problem)
Afficher commentaires plus anciens
I need to solve below non-linear equation with a range but cannot find a way to do it
Range of (x) is -40 to 30 with increments of 5. (x) is known but I need to find range of (y) and plot (x) vs (y). Please with the answer provide an explanation also. Thank you
p=0.5
S=(sin(y-x)-p*sin(x)*sin(y))=0
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 7 Fév 2018
syms x y
p = 0.5;
eq = (sind(y-x)-p*sind(x)*sind(y)) == 0;
Y = simplify(solve(eq, x));
This gives you an explicit formula for Y. You can substitute particular numeric values for x into the formula.
MATLAB will return two expressions. If you analyze the expressions, they turn out to differ by 180 degrees. Further analysis shows that there an an infinite number of other solutions that are 180 apart.
3 commentaires
Abdullah Nasir
le 7 Fév 2018
Modifié(e) : Walter Roberson
le 7 Fév 2018
Walter Roberson
le 7 Fév 2018
Do not assign numeric values to x before the code that follows.
xvec = -40:5:30;
syms x y
p = 0.5;
eq = (sind(y-x)-p*sind(x)*sind(y)) == 0;
Y = simplify(solve(eq, y)); %typo fixed on this line
Yn = double( subs(Y, x, xvec) );
plot(xvec, real(Yn));
Abdullah Nasir
le 7 Fév 2018
Catégories
En savoir plus sur Numeric Solvers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
