distances = sqrt((x - max(x)).^2 + (y - max(y)).^2); [peaks, iPeaks] = findpeaks(distances);%to find out where the curve turns around
for i = 1 : length(iPeaks)-1 iPeaks1 = iPeaks(i); iPeaks2 = iPeaks(i+1)-1;%analyse of consecutive pair of peaks
%skip small noise peaks
if length(iPeaks1:iPeaks2)>=5 xx=x(iPeaks1:iPeaks2) yy=y(iPeaks1:iPeaks2) end endhello
i need to construct vectors xx and yy. The problem is that at each cycle the past xx and yy is deleted but i want the opposite. i want them to keep the past information and grow at each cycle. what can i do? and also i know i should preallocate xx and yy.
i appreciate any help. thank you very much.
**this is a possible solution. the problem here is i need to preallocate. but if i do it, the xx and yy keep the zeros and continue to grow 'with the zeros inside' and that is wrong
:
distances = sqrt((x - max(x)).^2 + (y - max(y)).^2); [peaks, iPeaks] = findpeaks(distances);%to find out where the curve turns around xx=[]; yy=[]; for i = 1 : length(iPeaks)-1 iPeaks1 = iPeaks(i); iPeaks2 = iPeaks(i+1)-1;%analyse of consecutive pair of peaks %skip small noise peaks if length(iPeaks1:iPeaks2)>=5 xx = [xx; x(iPeaks1:iPeaks2)];%''concatenate''(connect)
yy = [yy; y(iPeaks1:iPeaks2)]; end end
Best Answer