function [clutter , mean_n_FA , n_FA] = mkclutterV(T , LambdaV , V);
% Make clutter into hyper-cube V with a mean poisson noise process LambdaV.
%
%
% [clutter , mean_n_FA , n_FA] = mkclutterV(T , LambdaV , V);
%
%
% Inputs
% -----
%
% T Number of scans
%
% LambdaV mean number of false alarm per volume unit V = prod(diff(V));
%
% V Hypercube limits (2 x n) dimensions (dfaut V = [0 ; 2Pi])
%
%
% Outputs
% -----
%
% clutter Matrix (N x n + 1), N = n_1 +...+ n_T where n_i ~ Poisson(LambdaV).
% Clutter(: , 1) is time index.
%
% mean_n_FA Expected number of false alarms per volume unit
%
%
% Example
% -------
%
% T = 10;
% LambdaV = 2;
% V = [0 , -1000 ; 2*pi , 1000];
% clutter = mkclutterV(T , LambdaV , V);
%
%
%***************************************************************************%%
% Auteur Sbastien PARIS (sebastien.paris@lsis.org), Septembre 2002 %
%***************************************************************************%%
if (nargin <3)
V = [0 ; 2*pi];
end
[p , n] = size(V);
if(p ~=2)
error('V must be 2xn !!');
end
n_FA = poisrnd(LambdaV , T); % Tirage selon une loi de poisson du nombre de F.A par scan. E[mt] = Lambda*V
mean_n_FA = sum(n_FA)/T;
max_n_FA = max(n_FA);
O_max_n_FA = ones(max_n_FA , 1);
ind_T = (1 : T);
I = ind_T(O_max_n_FA , :);
R = [zeros(max_n_FA , 1) , triu( ones(max_n_FA ) )];
tp_ind = find( R( : , n_FA + 1 ) );
le_tp_ind = length(tp_ind);
Otp_ind = ones(le_tp_ind , 1);
a = V(1 , :);
b = V(2 , :) - V(1 , :);
clutter = [reshape(I( tp_ind ) , le_tp_ind , 1) , a(Otp_ind , :) + b(Otp_ind , :).*rand(le_tp_ind , n)];