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: JointDist.m
    path of file: ./repos/EEGapp/EEGapp/custom_stuff/Chronux/chronux_2_12/fly_track/FAnalyze/functions
    
    the code of the file until where you have to start completion: function [P bins] = JointDist(x,y,nbins)

%JOINTDIST
%   Usage: [P bins] = JointDist(x,y,nbins)
%
%This function calculates the joint distribution of the variables x and y.
%It is simply a normalized histogram using hist3. nbins can take any form
%of bins that hist3 can take, but no other hist3 options.

%Written by Dan Valente
%October 2007


    
function [P bins] = JointDist(x,y,nbins)

%JOINTDIST
%   Usage: [P bins] = JointDist(x,y,nbins)
%
%This function calculates the joint distribution of the variables x and y.
%It is simply a normalized histogram using hist3. nbins can take any form
%of bins that hist3 can take, but no other hist3 options.

%Written by Dan Valente
%October 2007

%ensure x and y are both column matrices
[nrowsx,ncolsx] = size(x);
if (ncolsx ~= 1)
    x = x';
end