Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. columns = 40;
  2. rows = 9;
  3. data = Table[i*100 + j, {i, rows}, {j, columns}];
  4. dt = 2;
  5. steplength = 5*dt;
  6. steps = Floor[columns/steplength];
  7. shifts = Floor[steplength/Abs[dt]];
  8. partdata = Partition[data, {rows, steplength}];
  9. Do[step[i] = partdata[[1]][[i]], {i, steps}];
  10. Do[dtstep[i] = Partition[step[i], {rows, Abs[dt]}], {i, steps}];
  11. Do[shiftdtstep[i][j] = ArrayPad[dtstep[i][[1]][[j]], {If[dt >= 0, {shifts - j, j - 1}, {j - 1, shifts - j}],{0,0}}], {i, steps}, {j, shifts}];
  12. Do[shiftedstep[i] = ArrayReshape[Transpose[Table[shiftdtstep[i][j], {j, shifts}]], {rows + shifts - 1,Abs[dt]*shifts}], {i, steps}];
  13. shifteddata = ArrayReshape[Transpose[Table[shiftedstep[i], {i, steps}]], {rows + shifts - 1, steps*steplength}];
  14. data // MatrixForm
  15. shifteddata // MatrixForm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement