MATLAB: I have a cell array of 1 x 8 size.I want to add a zero in between two cells.How do i do this in matlab

MATLAB

In MATLAB,I have a 1 x 8 cell array.The numbers are
-4.5,-1.5 ,-2.5,-1.2,1.2,2.5,1.5,4.5
I iterate through the whole cell.I take absolute values of each element.As soon as i encounter equal elements (Here it is going to be 1.2 and 1.2), i add a zero in between them. Overall it becomes a 1 x 9 cell array.Kindly help me with this.

Best Answer

>> V = [-4.5,-1.5 ,-2.5,-1.2,1.2,2.5,1.5,4.5];
>> Z = V;
>> Z(2,:) = 0;
>> Z = Z([true(size(V));~diff(abs(V)),false]).'
Z =
-4.50000 -1.50000 -2.50000 -1.20000 0.00000 1.20000 2.50000 1.50000 4.50000