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:
- to make room first array element overwritten
- every other element shifted @ new location
index-1---left shift. - 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
Post a Comment