keypoint.m

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

M
35
字号
function [keyda1]=keypoint(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-ratekeyda1(1)=data(1);[d,n]=size(data);j=2;for i=2:n-1   %求斜率   a=[data(i)-data(i-1)]/t;   b=[data(i)-data(i+1)]/t;   if a*b==1       e(i)=pi/2;    else    c=(b-a)/(1-a*b);   e(i)=atan(c);    %计算出的夹角  endend[f,ind]=sort(e)  %夹角排序  s=1;  for j=2:K+1      keyda1(j)=data(ind(s));      s=s+1;  end

⌨️ 快捷键说明

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