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
end
你好
我需要构造向量 xx 和 yy。问题是在每个周期中,过去的 xx 和 yy 都会被删除,但我想要相反。我希望他们保留过去的信息并在每个周期中成长。我能做些什么?而且我知道我应该预先分配 xx 和 yy。
我感谢任何帮助。非常感谢您。
* *这是一个可能的解决方案。这里的问题是我需要预先分配。但如果我这样做,xx 和 yy 会保持零并继续增长“内部有零”,这是错误的
:
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