For Loop conditon for peak position segmentation
Show older comments
Hello, I have segmented this signal and now I want to separate only the remarked peaks.

ThDif = 20000;
for odif = 1:length(G2)
if G2(odif)> ThDif
Qdif(odif)=G2(odif);
else Qdif(odif)=0
end
end
Pdif = find(Qdif>2);
Sdif = diff(Pdif);
Hdif(1) = Pdif(1);
pomDif = 2;
for adif = 1:length(Sdif)
if Sdif(adif)>1
Hdif(pomDif) = Pdif(adif);
Hdif(pomDif+1) = Pdif(adif+1);
pomDif=pomDif+2;
end
end
pom2dif=1;
for bdif = 1:2:length(Hdif)-1
[hodnDif pozDif] = max(G2(Hdif(bdif):Hdif(bdif+1)));
Mdif(pom2dif) = pozDif+Hdif(bdif);
pom2dif = pom2dif+1;
end
plot(data); hold on;
xlim([1 800]);
stem(Mdif,ones(1,length(Mdif))*300, 'r');
Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!