MATLAB: How to get the missing peak points

arraysplotwhile

Hi all, I just got some problem with this code unable to plot the points on some peaks.
close all
[NUM,TXT,RAW]=xlsread('b3br.csv');
[row,col] = size(NUM); t=NUM(:,1); len = (1:1:row); data=NUM(:,2); clf;
figure(1);
plot(t,data);
Z1=smooth(t,'rlowess'); Z2=smooth(data,14,'rloess'); figure(2); plot(t,Z2);
K = (diff(Z2)); %to calculate the difference in voltage K1 = abs(diff(Z2)); A1 = abs(Z2);
i = 1; j = 1; flag = 0; flag1 = 0; flag2 = 0; temp = 0;
record = ones(1,8);
while(i<row)
if(A1(i)>0.3) if( (A1(i+1) < (A1(i))) && flag == 0)
flag = 1;
record(j)= i;
j = j + 1;
else
if(A1(i) <= 0.5 && flag1 == 0 && flag == 1)
temp = i;
while(A1(temp) < A1(temp - 1))
temp = temp - 1;
end
record(j) = temp ;
j = j + 1;
flag1 = 1;
else
if(A1(i) <= 0.5 && flag2 == 0 && flag == 1)
temp = i;
while(A1(temp) < A1(temp - 1))
temp = temp + 1;
end
record(j) = temp ;
j = j - 1;
flag2 = 1;
end
end
end
i = i + 1;
else i = i + 1; flag = 0; flag1 = 0; flag2 = 0;
end
end
figure(3); plot(len,A1,len(record),A1(record),'r*');
figure(7); plot(len,Z2,len(record),Z2(record),'r*');

Best Answer

I don't see anything missing: I see it plotting all of the points that your program defines for it to plot.
If you see something as being missing, you are going to have to describe for us what you want to be plotted and what it produces instead. And keep in mind that we don't have your input file, and you have (ahem) omitted posting copies of the output, so we cannot see what you are seeing.