声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2412|回复: 5

[其他] 如何做一个波形上(极大值点)、下(极小值点) 包络线?

[复制链接]
发表于 2008-11-23 13:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
如题,如何做一个波形上(极大值点)、下(极小值点) 包络线?
我一点思路都没有,大家帮帮忙啊
回复
分享到:

使用道具 举报

发表于 2008-11-23 13:55 | 显示全部楼层
搜一下包络线! 论坛上有
发表于 2008-11-23 17:07 | 显示全部楼层
本帖最后由 VibInfo 于 2016-10-21 15:25 编辑
原帖由 wzhstone 于 2008-11-23 13:44 发表
如题,如何做一个波形上(极大值点)、下(极小值点) 包络线?
我一点思路都没有,大家帮帮忙啊

转载一个求上下包络的函数:
function [up,down] = envelope(x,y,interpMethod)
%ENVELOPE gets the data of upper and down envelope of the known input (x,y).
%
%   Input parameters:
%    x               the abscissa of the given data
%    y               the ordinate of the given data
%    interpMethod    the interpolation method
%
%   Output parameters:
%    up      the upper envelope, which has the same length as x.
%    down    the down envelope, which has the same length as x.
%

if length(x) ~= length(y)
    error('Two input data should have the same length.');
end
if (nargin < 2)|(nargin > 3),
error('Please see help for INPUT DATA.');
elseif (nargin == 2)
    interpMethod = 'linear';
end

   
% Find the extreme maxim values
% and the corresponding indexes
%----------------------------------------------------
extrMaxValue = y(find(diff(sign(diff(y)))==-2)+1);
extrMaxIndex =   find(diff(sign(diff(y)))==-2)+1;

% Find the extreme minim values
% and the corresponding indexes
%----------------------------------------------------
extrMinValue = y(find(diff(sign(diff(y)))==+2)+1);
extrMinIndex =   find(diff(sign(diff(y)))==+2)+1;

up = extrMaxValue;
up_x = x(extrMaxIndex);
down = extrMinValue;
down_x = x(extrMinIndex);

% Interpolation of the upper/down envelope data
%----------------------------------------------------
up = interp1(up_x,up,x,interpMethod);
down = interp1(down_x,down,x,interpMethod);

调试程序
%   DEMOENVELOPE shows how to use function envelope to obtain the
%   upper/down envelope of a given data and plot the envelope.
%

clc;
% Load a signal waveform
%--------------------------------------------
N = 100;
fs = 50;
t = ((1:N)/512)';
T0 = 0.01;
f0 = 12.7;
T1 = 0.026;
f1 = 35.8
y = exp(-T0*t) .* 5 .* sin(2*pi * f0*t) + exp(-T1*t).*4.*sin(2*pi*f1*t);
%load data.txt data;
%t = data(:,1); % time series
%y = data(:,2); % signal data
figure(1);
plot(t,y,'b-');
title('The original signal waveform','FontSize',18);

% Call function envelope to
% obtain the envelope data
%--------------------------------------------
[up,down] = envelope(t,y,'linear');

% Show the envelope alone
%--------------------------------------------
figure(2)
plot(t,up); hold on;
plot(t,down);
title('The envelope of the given signal data','FontSize',18);
hold off;

% Show the original signal and its envelope
%--------------------------------------------
figure(3)
plot(t,y,'g-'); hold on;
plot(t,up,'r-.');
plot(t,down,'r-.');
title('The envelope vs the given signal data','FontSize',18);
hold off;

[ 本帖最后由 songzy41 于 2008-11-23 17:08 编辑 ]
发表于 2008-11-24 12:25 | 显示全部楼层
若有重复点即发生一些小问题, 各位大大对如何解决是否有好意见?
http://forum.vibunion.com/forum/thread-32967-2-1.html
发表于 2012-5-9 17:03 | 显示全部楼层
回复 3 # songzy41 的帖子

您好,你现在还做这个吗?
发表于 2012-5-10 09:08 | 显示全部楼层
我只知道这个是用三次插值做的,可以用函数spline……不知道对你是不是有帮助
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 13:44 , Processed in 0.054283 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表