function [gamma] = SINR_calculation(Q,P,w,rho,H,sigma2,M,K,N)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

% Channel gain at each point is calculated
channel = zeros(N,K,M) ; 
gamma   = zeros(N,K,M) ; 

for n = 1:N
    for k = 1 : K
        for m = 1: M
            channel(n,k,m) =    rho /(H^2 + norm(Q(n,:,m)-w(k,:),2)^2)  ;
%             channel(n,k,m) =    rho /(H.^2 + norm(Q(n,:,m)-w(k,:),2).^2)  ;
        end
    end
end
% SINR at each point
for n = 1:N
    for k = 1 : K
        for m = 1: M
            if M > 1
                gamma(n,k,m) =   (P(n,m)*channel(n,k,m)) / (sigma2 + sum(P(n,[1:M] ~= m ).*channel(n,k,[1:M]~=m)));
            else
                gamma(n,k,m) =   (P(n,m)*channel(n,k,m)) / (sigma2) ; 
            end
        end
    end
end

end

