检波形的波峰与波谷

检波形的波峰与波谷
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
%        [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
%        maxima and minima ("peaks") in the vector V.
%        MAXTAB and MINTAB consists of two columns. Column 1
%        contains indices in V, and column 2 the found values.
%      
%        With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
%        in MAXTAB and MINTAB are replaced with the corresponding
%        X-values.
%
%        A point is considered a maximum peak if it has the maximal
%        value, and was preceded (to the left) by a value lower by
%        DELTA.

% Eli Billauer, 3.4.05 (Explicitly not copyrighted).
% This function is released to the public domain; Any use is allowed.

maxtab = [];
mintab = [];

v = v(:); % Just in case this wasn't a proper vector

if nargin < 3
  x = (1:length(v))';
else 
  x = x(:);
  if length(v)~= length(x)
    error('Input vectors v and x must have same length');
  end
end
  
if (length(delta(:)))>1
  error('Input argument DELTA must be a scalar');
end

if delta <= 0
  error('Input argument DELTA must be positive');
end

mn = Inf; mx = -Inf;
mnpos = NaN; mxpos = NaN;

lookformax = 1;

for i=1:length(v)
  this = v(i);
  if this > mx, mx = this; mxpos = x(i); end
  if this < mn, mn = this; mnpos = x(i); end
  
  if lookformax
    if this < mx-delta
      maxtab = [maxtab ; mxpos mx];
      mn = this; mnpos = x(i);
      lookformax = 0;
    end  
  else
    if this > mn+delta
      mintab = [mintab ; mnpos mn];
      mx = this; mxpos = x(i);
      lookformax = 1;
    end
  end
end

 

波峰波谷

06-24

[img=http://img.bbs.csdn.net/upload/201306/24/1372071142_126818.jpg][/img]rnrn问题描述:rn对于任意给出的一组随机数列,求出离给出点和指定区间(即给出点往前多少个单位)最近的上波浪或下波浪,结果表示为两个点的坐标。rn如给出的点在B与C之间,给出的指定区间为30,则答案为(3,5.15)和(24,3.3),即A、B两个点的坐标。rn给出的点在E、F之间,给定的区间为30,则答案为(54,3.3)和(62,4.55),即D、E两点的坐标rnrn大家能帮忙想一下吗?rnrn数据:rn(1,4.6)(2,4.7)(3,5.15)(4,5.05)(5,5.1)(6,4.8)(7,4.7)(8,4.65)(9,4.7)(10,4.4)(11,4.0)(12,3.85)(13,3.65)(14,3.7)(15,3.85)(16,4.05)(17,3.8)(18,3.95)(19,4.0)(20,3.9)(21,3.65)(22,3.85)(23,3.5)(24,3.3)(25,3.3)(26,3.35)(27,3.35)(28,3.55)(29,3.45)(30,3.75)(31,4.15)(32,4.0)(33,4.05)(34,4.25)(35,4.1)(36,3.85)(37,3.95)(38,4.15)(39,4.0)(40,4.0)(41,3.75)(42,3.35)(43,3.25)(44,3.9)(45,4.0)(46,4.0)(47,4.05)(48,3.85)(49,3.85)(50,3.45)(51,3.4)(52,3.45)(53,3.4)(54,3.3)(55,3.7)(56,4.0)(57,4.15)(58,3.95)(59,4.2)(60,4.3)(61,4.45)(62,4.55)(63,4.5)(64,3.95)(65,3.8)(66,3.75)(67,3.7)(68,3.75)(69,3.75)(70,3.8)(71,3.75)(72,3.7)(73,3.75)(74,3.6)(75,3.2)(76,3.25)(77,3.2)(78,3.05)(79,2.8)(80,2.9)(81,2.75)(82,2.85)(83,2.85)(84,2.85)(85,2.85)(86,3.15)(87,3.6)(88,3.9)(89,3.95)(90,4.05)(91,3.75)(92,3.75)(93,4.15)(94,4.15)(95,4.35)(96,4.1)(97,4.0)(98,4.1)(99,4.4)(100,4.25)(101,4.35)(102,4.15)(103,4.15)(104,4.1)(105,4.2)(106,4.0)(107,3.9)(108,3.65)(109,3.85)(110,3.7)(111,3.75)(112,3.8)(113,3.35)(114,3.55)(115,3.35)(116,3.3)(117,3.5)(118,3.6)(119,3.35)(120,3.3)(121,3.55)(122,3.75)(123,3.75)(124,4.0)(125,4.0)(126,3.95)(127,3.7)(128,3.6)(129,3.4)(130,3.65)(131,3.6)(132,3.55)(133,3.6)(134,3.3)(135,3.55)(136,3.55)(137,3.2)(138,3.1)(139,3.1)(140,3.2)(141,3.35)(142,3.2)(143,3.45)(144,3.2)(145,3.15)(146,3.25)(147,3.2)(148,3.5)(149,3.5)(150,3.4)(151,3.5)(152,4.1)(153,4.3)(154,4.35)(155,4.1)(156,4.0)(157,4.0)(158,4.15)(159,4.2)(160,4.2)(161,3.75)(162,3.8)(163,3.55)(164,3.7)(165,3.75)(166,3.6)(167,3.55)(168,3.35)(169,3.35)(170,3.3)(171,3.3)(172,2.7)(173,2.6)(174,2.6)(175,2.85)(176,3.05)(177,3.35)(178,3.1)(179,3.0)(180,3.05)(181,3.55)(182,3.7)(183,3.7)(184,4.2)(185,4.1)(186,4.2)(187,4.2)(188,4.1)(189,4.3)(190,4.25)(191,4.35)(192,4.45)(193,4.6)(194,4.6)(195,4.35)(196,4.4)(197,4.45)(198,4.45)(199,4.7)(200,4.75)(201,4.8)(202,4.6)(203,4.65)(204,4.05)(205,4.1)(206,4.05)(207,4.25)(208,4.3)(209,4.45)(210,4.55)(211,4.5)(212,4.65)(213,4.3)(214,4.75)(215,4.9)(216,4.6)(217,4.25)(218,4.5)(219,4.25)(220,4.35)(221,3.9)(222,4.15)(223,4.45)(224,4.5)(225,4.45)(226,4.35)(227,4.4)(228,4.35)(229,4.0)(230,3.9)(231,3.75)(232,3.7)(233,3.75)(234,3.45)(235,3.5)(236,3.5)(237,4.2)(238,4.0)(239,4.1)(240,3.85)(241,3.7)(242,3.4)(243,3.15)(244,3.1)(245,3.1)(246,3.4)(247,3.6)(248,3.7)(249,3.8)(250,3.85)(251,3.85)(252,3.7)(253,3.7)(254,3.65)(255,3.75)(256,4.0)(257,3.45)(258,3.55)(259,3.8)(260,3.95)(261,3.95)(262,4.0)(263,4.15)(264,4.2)(265,4.25)(266,3.95)(267,3.6)(268,3.5)(269,3.55)(270,3.45)(271,3.65)(272,3.9)(273,3.9)(274,4.2)(275,3.95)(1,4.6)(2,4.7)(3,5.15)(4,5.05)(5,5.1)(6,4.8)(7,4.7)(8,4.65)(9,4.7)(10,4.4)(11,4.0)(12,3.85)(13,3.65)(14,3.7)(15,3.85)(16,4.05)(17,3.8)(18,3.95)(19,4.0)(20,3.9)(21,3.65)(22,3.85)(23,3.5)(24,3.3)(25,3.3)(26,3.35)(27,3.35)(28,3.55)(29,3.45)(30,3.75)(31,4.15)(32,4.0)(33,4.05)(34,4.25)(35,4.1)(36,3.85)(37,3.95)(38,4.15)(39,4.0)(40,4.0)(41,3.75)(42,3.35)(43,3.25)(44,3.9)(45,4.0)(46,4.0)(47,4.05)(48,3.85)(49,3.85)(50,3.45)(51,3.4)(52,3.45)(53,3.4)(54,3.3)(55,3.7)(56,4.0)(57,4.15)(58,3.95)(59,4.2)(60,4.3)(61,4.45)(62,4.55)(63,4.5)(64,3.95)(65,3.8)(66,3.75)(67,3.7)(68,3.75)(69,3.75)(70,3.8)(71,3.75)(72,3.7)(73,3.75)(74,3.6)(75,3.2)(76,3.25)(77,3.2)(78,3.05)(79,2.8)(80,2.9)(81,2.75)(82,2.85)(83,2.85)(84,2.85)(85,2.85)(86,3.15)(87,3.6)(88,3.9)(89,3.95)(90,4.05)(91,3.75)(92,3.75)(93,4.15)(94,4.15)(95,4.35)(96,4.1)(97,4.0)(98,4.1)(99,4.4)(100,4.25)(101,4.35)(102,4.15)(103,4.15)(104,4.1)(105,4.2)(106,4.0)(107,3.9)(108,3.65)(109,3.85)(110,3.7)(111,3.75)(112,3.8)(113,3.35)(114,3.55)(115,3.35)(116,3.3)(117,3.5)(118,3.6)(119,3.35)(120,3.3)(121,3.55)(122,3.75)(123,3.75)(124,4.0)(125,4.0)(126,3.95)(127,3.7)(128,3.6)(129,3.4)(130,3.65)(131,3.6)(132,3.55)(133,3.6)(134,3.3)(135,3.55)(136,3.55)(137,3.2)(138,3.1)(139,3.1)(140,3.2)(141,3.35)(142,3.2)(143,3.45)(144,3.2)(145,3.15)(146,3.25)(147,3.2)(148,3.5)(149,3.5)(150,3.4)(151,3.5)(152,4.1)(153,4.3)(154,4.35)(155,4.1)(156,4.0)(157,4.0)(158,4.15)(159,4.2)(160,4.2)(161,3.75)(162,3.8)(163,3.55)(164,3.7)(165,3.75)(166,3.6)(167,3.55)(168,3.35)(169,3.35)(170,3.3)(171,3.3)(172,2.7)(173,2.6)(174,2.6)(175,2.85)(176,3.05)(177,3.35)(178,3.1)(179,3.0)(180,3.05)(181,3.55)(182,3.7)(183,3.7)(184,4.2)(185,4.1)(186,4.2)(187,4.2)(188,4.1)(189,4.3)(190,4.25)(191,4.35)(192,4.45)(193,4.6)(194,4.6)(195,4.35)(196,4.4)(197,4.45)(198,4.45)(199,4.7)(200,4.75)(201,4.8)(202,4.6)(203,4.65)(204,4.05)(205,4.1)(206,4.05)(207,4.25)(208,4.3)(209,4.45)(210,4.55)(211,4.5)(212,4.65)(213,4.3)(214,4.75)(215,4.9)(216,4.6)(217,4.25)(218,4.5)(219,4.25)(220,4.35)(221,3.9)(222,4.15)(223,4.45)(224,4.5)(225,4.45)(226,4.35)(227,4.4)(228,4.35)(229,4.0)(230,3.9)(231,3.75)(232,3.7)(233,3.75)(234,3.45)(235,3.5)(236,3.5)(237,4.2)(238,4.0)(239,4.1)(240,3.85)(241,3.7)(242,3.4)(243,3.15)(244,3.1)(245,3.1)(246,3.4)(247,3.6)(248,3.7)(249,3.8)(250,3.85)(251,3.85)(252,3.7)(253,3.7)(254,3.65)(255,3.75)(256,4.0)(257,3.45)(258,3.55)(259,3.8)(260,3.95)(261,3.95)(262,4.0)(263,4.15)(264,4.2)(265,4.25)(266,3.95)(267,3.6)(268,3.5)(269,3.55)(270,3.45)(271,3.65)(272,3.9)(273,3.9)(274,4.2)(275,3.95)

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试