title: How to implement this function in a single line in MATLAB (Revised)
body: <p>Please help me in minimizing this for loop to a single line.</p>
  
  <p>I have a set of dataset which is represented as 4D light field data. The four indices are u, v, s and t. Mathematically, I found a way to transform this 4D light field data to another coordinate system. The new coordinates will be a 3D rotated and translated version of previous system.</p>
  
  <p>The resulting indices of the transformed light field data are ub, vb, sb, tb.
  Each of them is depending on variables u,v,s,t.</p>
  
  <p>Sorry for being unclear, let me mention that I am trying to transform a 4D dataset through some sort of matrix. In the code below M is simply a 3D transformation matrix.</p>
  
  <pre><code>f=0.1; 
  n = 11; 
  [u,v,s,t] = ndgrid([1:Size(3)],[1:Size(4)],[1:Size(1)],[1:Size(2)]); 
  alpha = M(3,1)*s+M(3,2)*t+M(3,3)*nf; 
  beta1 = M(1,1)*u+M(1,2)*v+M(1,4); 
  beta2 = M(2,1)*u+M(2,2)*v+M(2,4); 
  C = M(3,1)*u+M(3,2)*v+M(3,4); 
  D1 = M(1,1)*s+M(1,2)*t+M(1,3)*nf; 
  D2 = M(2,1)*s+M(2,2)*t+M(2,3)*nf; 
  ub = -D1.*C./alpha+beta1; 
  vb = -D2.*C./alpha+beta2; 
  sb = nf*D1./alpha; 
  tb = nf*D2./alpha; 
  for s = 1:Size(1) 
      for t = 1:Size(2) 
          for u = 1:Size(3) 
              for v = 1:Size(4)             
                  newLF(sb(u,v,s,t),tb(u,v,s,t),ub(u,v,s,t),vb(u,v,s,t)) = LF2(s,t,u,v); 
              end;
          end; 
      end;
  end;  
  </code></pre>
  
  <p>Now since ub,vb,sb and tb are depending on u,v,s,t therefore, it is not possible to assign it like newLF = LF2;</p>
  
  <p>Now the question is how to minimize these for loops to a single line.</p>