You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: natfrequency.m
    path of file: ./repos/MSS/HYDRO/utils
    
    the code of the file until where you have to start completion: function w_n = natfrequency(vessel,dof,w_0,speed,LCF)
% NATFREQUENCY (MSS Hydro)
%
% w_n = natfrequency(vessel,dof,w_0,speed,LCF) computes the natural
% frequency in heave, roll, and pitch w.r.t. the Centre of Flotation (CF), i.e.
% the centroid of the water plane area.  For small angles, a starboard-port
% symmetrical vessel the decoupled pitching and rolling motions will be

    
function w_n = natfrequency(vessel,dof,w_0,speed,LCF)
% NATFREQUENCY (MSS Hydro)
%
% w_n = natfrequency(vessel,dof,w_0,speed,LCF) computes the natural
% frequency in heave, roll, and pitch w.r.t. the Centre of Flotation (CF), i.e.
% the centroid of the water plane area.  For small angles, a starboard-port
% symmetrical vessel the decoupled pitching and rolling motions will be
% about the point [LFC, 0, 0] in CO where CO is the b-frame coordinate
% origin midtships on the centre line (Lpp/2, B/2, WL) and LCF denotes the
% longitudinal centre of floatation (usually negative). IF LCF is omitted it
% is assumed that CF = CO.  
%
% For a linear system, the harmonic motions in 6 DOF satisfy
%
%    -[M_RB + A(w)] * w^2 + C = 0
%
% which reduces to
%
%    w_i = sqrt( C_ii / (M_RB_ii + A_ii(w_i) )
%
% for the 1 DOF case. These are implicit equations f(x) = 0 that are solved
% using fsolve.m (requires optimization toolbox) alternatively fzero.m.
%
% 6-DOF example: 
% >> w_n = natfrequency(vessel,-1,0.5,1)    
%
% 1-DOF examples:
% >> w_n = natfrequency(vessel,4,0.5,1,LCF)
% >> w_n = natfrequency(vessel,4,0.5,1)
%
% Inputs:
%    vessel    MSS vessel data (computed in CO)
%    dof       degree of freedom (3,4 or 5). Use -1 for 6 DOF coupled data
%    w_0       initial natural frequency (typical 0.5)
%    speed     speed index 1,2,3...
%    LCF       optionally, longitudinal distance to CF from CO
%              (x-coordinate of the water plane centroid)
% Outputs:
%    w_n       natural frequency
%
% Author:    Thor I. Fossen
% Date:      2006-03-26
% Revisions: 2008-01-23 only for 1 DOF
%            2008-10-28 updated to solve 6-DOF coupled motions
%            2019-05-03 updated documentation
% _________________________________________________________________________
%
% MSS HYDRO is a Matlab toolbox for guidance, navigation and control.
% The toolbox is part of the Marine Systems Simulator (MSS).
%

%% Solve frequency-depend