I have a 1x1033 column vector in MATLAB that mostly consists of zeros - every so often, there are two numbers adjacent to one another that are either side of zero (i.e. if the first number is positive, the second is negative and vice versa). I am trying to input zeros between these two values without adding zeros at any other point in the matrix. I thought I had it, but my loop only adds a zero between the first two non-zero values, and ignores the rest.
Any help would be appreciated.
my code is shown below: for h = n:-1:1; zero_crossing_markers(h);
if zero_crossing_markers(h) > 0 && zero_crossing_markers(h+1) < 0;
%zero_values_added = [zero_crossing_markers(1:h), 0, zero_crossing_markers(h+1:n)];
A = zero_crossing_markers(1:h);
B = 0;
C = zero_crossing_markers(h+1:n);
zero_values_added = [A, B, C];
else if zero_crossing_markers(h) < 0 && zero_crossing_markers(h+1) > 0;
%zero_values_added = [zero_crossing_markers(1:h), 0, zero_crossing_markers(h+1:n)];
A = zero_crossing_markers(1:h);
B = 0;
C = zero_crossing_markers(h+1:n);
zero_values_added = [A, B, C];
else
zero_values_added(h) = 0;
end
end
end