1% Number state filtered coherent state, NSFCS (Sec. II.F)
2% A coherent state with one number state |m> removed from the superposition,
3% then renormalized.
5clear; % Clear memory
6clc; % Clear the command window/screen
7d = 15;
8m = 4; % number state |4> will be absent from the distribution
9I = eye(d);
10alpha = 0.8; % amplitude of the coherent state
11nsfs = 0; % initialization
12for x = 0:d-1
13 if x == m
14 nsfs = nsfs + 0*I(:,x+1);
15 else
16 nsfs = nsfs + exp(-norm(alpha)^2/2)*alpha^x/sqrt(prod(1:x))*I(:,x+1);
17 end
18end
19NSFS = nsfs/norm(nsfs) % normalize the state (note the 5th element is 0)