Given an array V, which is the numerical solution of a system of differential equations, I want to determine the local, positive peaks of this array. Every time I have such a peak whose value is greater than 0 I code a bit equal to 1 and every time I have a peak with a negative value I code a bit equal to 0(I cannot use findpeaks).
I have tried the following:
function Suite_bits = message_digital(V)
j = 1;
bit(1) = 0;
for i=2:numel(V)-1
if V(i-1)<V(i) && V(i+1)<V(i)
if V(i)>0
bit(j) = 1;
j = j + 1;
else
bit(j) = 0;
j = j + 1;
end
end
Suite_bits = bit;
end
But due to some minor anomalies in the vector V, fluctuations of the values between steps (remember V is the solution of a numerically solved ode system with a step h = 0.1), I get more peaks than actually appear in the graph. Any ideas how I could fix this?