title: Matlab FFT2 normalization after processing
body: <p>I am trying to understand how the MATLAB FFT normalization works.</p>
  
  <p>Lets discuss the following example.</p>
  
  <pre><code>%%
  sum2D = @(a) sum(reshape(a,1,[]));             % sum elements in 2D matrix
  
  a = [0 0 0; 1 2 1; 1 1 1; 1 1 1; 0 0 0]
  
  f1 = fft2(a)
  
  m = [0 32 0; 0 0 0; 0 1 0; 0 2 0; 0 0 0]
  
  fs = m.*fftshift(f1);
  fs = fs./sqrt(numel(fs));
  
  fm = ifft2(fs);
  fm = fm.*sqrt(numel(fm))
  
  % imshow(abs(fs))
  
  norm(a(:))^2,norm(fs(:))^2,norm(fm(:))^2
  
  sum2D(abs(a).^2)
  sum2D(abs(fs).^2)
  sum2D(abs(fm).^2)
  sum2D(abs(fp).^2)
  </code></pre>
  
  <p>If the m = 1, the normalization works and the energy is the same in the initial signal, fft and inverse fft. But if I multiply the signal after making fft by some vector m, then I don't know how to normalize this again. </p>
  
  <p>Should the energy change after multiplying with the m, or I am doing something wrong. </p>