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: sw_omegasum.m
    path of file: ./repos/spinw/swfiles
    
    the code of the file until where you have to start completion: function spectra = sw_omegasum(spectra, varargin)
% removes degenerate and ghost magnon modes from spectrum
% 
% ### Syntax
% 
% `spec = sw_omegasum(spec,Name,Value)`
% 
% ### Description

    
function spectra = sw_omegasum(spectra, varargin)
% removes degenerate and ghost magnon modes from spectrum
% 
% ### Syntax
% 
% `spec = sw_omegasum(spec,Name,Value)`
% 
% ### Description
% 
% `spec = sw_omegasum(spec,Name,Value)` removes the degenerate modes from
% the dispersion stored in `spec.omega` and sorts the modes according to
% increasing energy. It also removes ghost modes if a lower intensity limit
% is given.
%  
% The degenerate energies are substituted with `NaN` values.
%
% {{warning Be carefull, after this function [sw_egrid] won't work properly.
% This function won't work with spectra of multiple twins.}}
% 
% ### Name-Value Pair Arguments
% 
% `'tol'`
% : Energy tolerance, within the given value two energies are considered
%   equal. Default value is $10^{-5}$.
% 
% `'zeroint'`
% : The minimum intensity value, below which the mode is removed. Default
%   value is 0 (no modes are dropped due to weak intensity).
% 
% `'emptyval'`
% : Value that is assigned to modes that are removed. Default value is NaN
%   (good for plotting). 0 can be used if further numerical analysis, such
%   as binning will be applied.
% 
% ### See Also
% 
% [spinw.spinwave] \| [sw_egrid]
%

if iscell(spectra.omega)
    error('sw_omegasum:NoTwin','The sw_omegasum() function doesn''t work for spectra calculated for multiple twins!');
end