title: How do I shift columns (left or right) in a matrix?
body: <p>I would like to non-circularly shift my matrix and then have zeros padded to either the left or right (depending on the shift) i.e. if the matrix shifts to the right, zeros would be padded to the left.</p>
  <p>I am using MATLAB 2019b and my code so far looks like this:</p>
  <pre><code>%dummy data
  data = rand(5, 16);
  
  channelSink = 9; %this variable will either be &gt;layerIV, &lt;layerIV or =layerIV
  layerIV = 7;
  diff = layerIV - channelSink;
  
  for channel = 1:16
      
          if channelSink &gt; layerIV 
              
              %shift columns to the left by ab(diff)
              %and
              %set columns shifted by ab(diff) to zero
              
          elseif channelSink &lt; layerIV
              
              %shift columns to the right by diff
              %and
              %set columns shifted by diff to zero
              
          else %idiff = 0, don't shift
                
                diff = 0; 
                disp('Sink at channel 7; not necessary to re-align');
               
          end
          
      end
  </code></pre>
  <p>Thank you in advance</p>