keypiontall.m

来自「自己编写的实现时间序列中的关建点搜索」· M 代码 · 共 48 行

M
48
字号
function [g,keypoint]=keypiontall(data,K,t)%function [ keyda1,keyda2,keydata ] = keypoint( data,m,n,t)%UNTITLED1 Summary of this function goes here%  Detailed explanation goes here%keyda1 存储夹角方法取得的关键点%keyda2 存储幅值方法取得的关键点%data is the time series data which you want to search key point%m is the threshold value of angle%n is the threshold value of amplitude%t is the time per sample-rate%keyda1(:,1)=data(:,1);[d,n]=size(data); %d 为行,n 为例for i=1:dfor j=2:n-1   %求斜率   a=[data(i,j)-data(i,j-1)]/t;   b=[data(i,j)-data(i,j+1)]/t;   if a*b==1       e(i)=pi/2;   else    c=(b-a)/(1-a*b);   e(j)=atan(c);    %计算出的夹角     endend    [f,ind]=sort(e); %夹角排序      g(i,:)=ind(1:K); end%hist [m,n]=hist(g,n-1);  % the m record the element's times[a,b]=size(m)for i=1:ainde(i)=sum(m(i,:));end[p,q]=sort(inde);keypoint=q(1:K);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?