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: cohac.m
    path of file: ./repos/acycle/code/misc
    
    the code of the file until where you have to start completion: function [Cxy,F1,Pxy,F2] = cohac(x,y,sr,window,winsize,nooverlap,threshold,qplot)
% calculate coherence and phase for x and y
% INPUT
% x: first data vector
% y: second data vector
% sr: sampling rate
% window: window style;
%   'hamming'
%   https://www.mathworks.com/help/signal/ug/windows.html

    
function [Cxy,F1,Pxy,F2] = cohac(x,y,sr,window,winsize,nooverlap,threshold,qplot)
% calculate coherence and phase for x and y
% INPUT
% x: first data vector
% y: second data vector
% sr: sampling rate
% window: window style;
%   'hamming'
%   https://www.mathworks.com/help/signal/ug/windows.html
% nooverlap: number of overlap
% threshold: coherence threshold, must be >= 0 and <= 1;
% qplot: 0 = no; 1 = coherence+phase; 2 = coherence+phase+polarscatter; 
% 
% OUTPUT
%   Cxy: coherence of x and y
%   F1: frequency for Cxy
%   Pxy: phase of x and y
%   F:  frequency for Pxy
% EXAMPLE
%
% Fs = 1000;
% t = 0:1/Fs:1-1/Fs;
% x = cos(2*pi*100*t) + sin(2*pi*200*t) + 0.5*randn(size(t));
% y = 0.5*cos(2*pi*100*t - pi/4) + 0.35*sin(2*pi*200*t - pi/2) + 0.5*randn(size(t));
% cohac(x,y)
% cohac(x,y,1,'hamming',100,80,.2)
%
% Mingsong Li
% Penn State; March 14, 2019
% 
%
if nargin < 8; qplot = 2; end