Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Insert values into an array

Asked by Joe Abraham on 5 Jul 2012

A = [1 3 5 6 7 13]

I want to insert 0 in the 1st cell resulting in

A=[0 1 3 5 6 7 13]

Thanks

0 Comments

Joe Abraham

Products

1 Answer

Answer by Walter Roberson on 5 Jul 2012
Accepted answer
A = [0 A];  %build new array

Or:

A(2:end+1) = A;  %shift over and zero
A(1) = 0;

0 Comments

Walter Roberson

Contact us