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: nmt_ts_intervalpower.m
    path of file: ./repos/fieldtrip/contrib/nutmegtrip/private
    
    the code of the file until where you have to start completion: function fun = nmt_ts_intervalpower(fun,meantype)

    
function fun = nmt_ts_intervalpower(fun,meantype)
% when time interval is selected, calculate desired representation of interval power
switch(meantype)
    case 'msq' % mean power
        fun = mean(fun.^2,3); % average over freq dimension first, if present
        fun = mean(fun.^2,2);
    case 'rms' % RMS power
        fun = sqrt(mean(fun.^2,3));
        fun = sqrt(mean(fun.^2,2));
    case 'mean'  % simple average
        fun = mean(fun,3);
        fun = mean(fun,2);
end