www.pudn.com > MutualInformationICA.zip > MIxnyn.m


function miout=MIxnyn(x,y,kneig);

% Calculate MI value between 2 vector of any dimension (rectangular
% version)
% x....input data mxn   m...channelnummer  n...sampling points  m<Nx
    x=x';
    [Ndx,Nx]=size(x);
end
[Ndy,Ny]=size(y);
if Ndy>Ny
    y=y';
    [Ndy,Ny]=size(y);
end

if Nx~=Ny
    if Nx>Ny
        N=Ny;
    else
        N=Nx;
    end
    fprintf('The two input vectors must have the same length !!!!');
    fprintf('Caluculation using the %d datapoints',N);
    
else
    N=Nx;    
end


% save data for C-Programm
zwsp=[x;y]';
save zwspMIxnyn.txt zwsp -ASCII


% execute C Programm
[a unout]=unix(['MIxnyn zwspMIxnyn.txt ',num2str(Ndx),' ',num2str(Ndy),' ',num2str(N),' ',num2str(kneig)]);
miout=str2num(unout);