How to solve this system of nonlinear equations with parameters?

1 view (last 30 days)
I've got some problems solving (numerically) this system of equations.
40⋅cos(2t)+105⋅cos(θ3)−75⋅cos(θ4)−91.924⋅cos(337.62(deg))=0 40⋅sin(2t)+105⋅sin(θ3)−75⋅sin(θ4)−91.924⋅sin(337.62(deg))=0
Now t is an array of numbers (variable?) ranging from 0 to 0.785 like this t = 0:0.01:0.785.
I was wondering if it is possible to find theta3 and theta4 for every t (like t=0 --> theta3=something, theta4=something...t=0.4-->theta3="something else", theta4="something else") put those values(solutions) in an array (vecotr)so that I can plot them.
I've tried to do it symbolically with solve but MATLAB couldn't find any (useful) solution. I tried to solve it numerically but I couldn't make it spit out more than two solutions at a time.
I'm new to MATLAB.

Accepted Answer

Star Strider
Star Strider on 7 Apr 2014
Edited: Star Strider on 7 Apr 2014
The new equations help!
This seems to work:
time = 0:0.01:0.785;
% T(1) = theta3, T(2) = theta4
Eqsys2 = @(T,t) [40.*cos(2*t)+105.*cos(T(1))-75*cos(T(2))-91.924*cosd(337.62); 40*sin(2*t)+105*sin(T(1))-75*sin(T(2))-91.924*sind(337.62)];
for k1 = 1:length(time)
t = time(k1);
[Th, fv] = fsolve(@(T)Eqsys2(T,t), rand(1,2));
Theta34(k1,:) = Th;
end
figure(1)
plot(time, Theta34(:,1), time, Theta34(:,2))
legend('\Theta_3', '\Theta_4', 'Location','NorthWest')
xlabel('t')
ylabel('\Theta')
axis([xlim -pi pi])
grid
  2 Comments
Shaban
Shaban on 7 Apr 2014
Thank you very much for your reply Star Strider.I appreciate it a LOT because I was expecting only some tips on how to do it but you solved the most part of my problem. Thanks again. :)
Star Strider
Star Strider on 7 Apr 2014
My pleasure!
It was actually an interesting problem for me to work on. I developed it to the extent I did because I always test the code I post, and had problems getting it to work with arbitrary values for ‘theta1’. I wasn’t going to post it until I could get it to work satisfactorily, and your value for ‘theta1’ allowed that. Besides, if you’re new to MATLAB, a relevant example would be more helpful in your learning it than abstract hints.

Sign in to comment.

More Answers (0)

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!