How to shift elements of an array to the left without using loops in matlab? -


i have fixed sized array in matlab. when want insert new element following:

  1. to make room first array element overwritten
  2. every other element shifted @ new location index-1 ---left shift.
  3. the new element inserted @ place of last element becomes empty shifting elements.

i without using loops.

i'm not sure understand question, think mean this:

a = [ a(1:pos) newelem a((pos+1):end) ] 

that insert variable (or array) newelem after position pos in array a.

let me know if works you!

[edit] ok, looks want use array shift register. can this:

a = [ a(2:end) newelem ] 

this take elements 2nd last of a , added newelem variable (or array) end.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -