% File Name:                    tugboats.m
%
% Calculates tension in cables connecting two tugboats to a ship, where one angle is varied through
% zero to 90 degrees. Output is stored in matrix 'tension'.
% 
% The problem reduces down to two simultaneous equations:
%       T2cos 30 + T1cos theta = 2000
%       T2sin 30 + T1cos theta = 0
% The objective of this script is to solve these equations for 0 <= theta <= 90.

T1 = zeros ( 1, 90 );
T2 = zeros ( 1, 90 );

for n = 1:90
        A = [ cosd ( 30 ), cosd ( n );
              sind ( 30 ), sind ( n ) ];
              
        temp = A \ [ 2000; 0 ]; % We use matrix left division instead of the inverse. This 
                                % method is superior.
        T1( i ) = temp( 1 );
        T2( i ) = temp( 2 );
end

tension = [ T1; T2 ]
