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: WWIIIpartitioned2full2D.m
    path of file: ./repos/tracacode/1911-COAWST/script/mfiles/swan_forc
    
    the code of the file until where you have to start completion: function [Sf,Sfth,Freq,Dir] = WWIIIpartitioned2full2D(Hsig,Tp,theta,sigma,gamma,freq,dth);
%
% function [Sf,Sfth,Freq,Dir] = WWIIIpartitioned2full2D(Hsig,Tp,theta,sigma,gamma,freq);
% Usage: 
% 
% This function takes bulk wave parameters (Significant Wave Ht., Peak Period, 
% Peak Direction and Directional Spreading) to create a frequency-directional ocean wave spectrum
% using
    
function [Sfth,Dir]=Directional_Distribution(Sf,theta,sigma,dth) 
%
% function [Sfth]=Directional_Distribution(Sf,theta,sigma) 
%
% 	Usage: 
% This function considers the frequency spectrum, peak direction and
% directional spreading (defined as spectral width in Wavewatch Data) and
% applies a cos^2s(theta-theta_peak) distribution where theta varies from 0
% to 360 degrees.
%
%	INPUT:
%		Sf    = Spectral Density as a function of frequency (units m^2/Hz)
%		theta = Peak Direction (of a partition) in degrees
%		sigma = Spectral Width/Directional Spreading in degrees
%       dth   = radial resolution of direction in degs
%	OUTPUT:
%		Sfth  = Frequency Directional Wave Spectrum (m^2/Hz/Deg)
%
% Nirnimesh Kumar and George Voulgaris
% Coastal Processes and Sediment Dynamics Lab
% Dept. of Earth and Ocean Sciences,
% Univ. of South Carolina, Columbia, SC
% 03/06/2013
%

Sf  = Sf(:);
Th  = (pi/180)*[dth:dth:360]';           % direction from 0 to 360 degrees
s   = round((2./((pi*sigma/180).^2))-1); %See Kuik et al. (1988) 
if s>80
    s=80;
end