% Code to implement Khatri-Rao product

function res =  krp(X,Y)
[M N] = size(X);
[P Q] = size(Y);
if( N ~= Q)
    beep;
    disp('Khatri Rao product. Dimensions mismatch');
    pause(1)
    beep
else
    res = zeros(M*P,N);
    for k=1:N
        res(:,k) = kron(X(:,k), Y(:,k));
    end
end
end