MATLAB: How to specify a number to the specified position in the array?

matlab instruction

matlab问题图.jpgHi guys, the question is that now I used 'zeros' command, to create an array which have 20 positions, then there are some data will be created to fill the array, and I want to point data to the specified position. For example, the No.1 data should stay in the first position, the end data should stay in the second position, the No.2 data should stay in the third position. Is there any function can help me arrange their positions? Thanks a lot !

Best Answer

a = [2 3 5 7 11];
out = [a;flip(a,2)];
out = out(1:numel(a));