24小时热门版块排行榜    

查看: 261  |  回复: 1

wsmwsj

新虫 (初入文坛)

[交流] 【求助】信号包络仿真 已有1人参与

请求好心人给我看看下面有关信号包络的程序运行为什么会出错?
我输入:x=0:10;
              y=cos(x);
              envelope(x,y,spline)
总是会出现x没有定义呢
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.
%
%   See also DIFF INTERP1

%   Designed by: Lei Wang, <WangLeiBox@hotmail.com>, 11-Mar-2003.
%   Last Revision: 21-Mar-2003.
%   Dept. Mechanical & Aerospace Engineering, NC State University.
% $Revision: 1.1 $  $Date: 3/21/2003 10:33 AM $

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);
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
mze04532:请勿纯表情回帖,再提醒一下~扣过金币就不再扣了 2010-09-26 23:35:41
2楼2010-09-26 20:04:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 wsmwsj 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见