MATLAB Answers

System of nonlinear equations

5 views (last 30 days)
I have tried the following code to solve a system of nonlinear equations, but it does not return the correct result which can be found on Wolfram Alpha: https://www.wolframalpha.com/input/?i=10cos15+%28%28t%2B+%282%29%2845-10sin%2815%29t%29%2F%2810sin15%2Bsqrt%2819.6*%2845-10sin%2815%29t%29%29%29%29%29+%3D+40
Can anyone suggest how I should modify the code? I want to store the value of t in another variable r that can be used for later computations.
syms t y a
%b(1) = 10*cos(15)*((t+ 2*(45-10*sin(15)*t)/(10*sin(15)+sqrt(19.62*(45-10*sin(15)*t)))))-40;
b(1) = (10*cos(15)*((t+ 2*(45-10*sin(15)*t))))*power(( 10*sin(15)+sqrt(19.62*(45-10*sin(15)*t))),-1)-40;
z = solve(b,t,y);
Xsoln = simplify(z.t);
subs(Xsoln,a)
r = a;

  0 Comments

Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 12 Feb 2020
Hi Aleem,
Wolfram Alpha is solving this numercially not analytiaclly so you might as well, too.
b = @(t) 10*cosd(15)*(t+ 2*(45-10*sind(15)*t)/(10*sind(15)+sqrt(19.6*(45-10*sind(15)*t))))-40;
fzero(b,1)
ans =
1.4850
One important change here is that you have to use sind(theta) instead of sin(theta) since the angles are in degrees. Also I changed 19.62 to 19.6, otherwise the answer will disagree with Wolfram Alpha.

  3 Comments

darova
darova on 13 Feb 2020
Remember about accepting the answer
David Goodmanson
David Goodmanson on 13 Feb 2020
thank you darova and aleem

Sign in to comment.

More Answers (0)

Sign in to answer this question.