24小时热门版块排行榜    

查看: 274  |  回复: 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 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 285求调剂 +3 AZMK 2026-03-24 3/150 2026-03-25 12:23 by userper
[考研] 282求调剂 +3 wcq131415 2026-03-24 3/150 2026-03-25 12:16 by userper
[考研] 271求调剂 +4 生如夏花… 2026-03-22 4/200 2026-03-25 11:25 by userper
[考研] 318求调剂 +5 plum李子 2026-03-21 8/400 2026-03-25 09:26 by aa331100
[考研] 生物学学硕求调剂 +7 小羊睡着了? 2026-03-23 10/500 2026-03-25 02:24 by 清风拂扬。 m
[考研] 085601求调剂总分293英一数二 +3 钢铁大炮 2026-03-24 3/150 2026-03-24 22:03 by bingxueer79
[考研] 311求调剂 +3 冬十三 2026-03-24 3/150 2026-03-24 21:31 by peike
[考研] 307求调剂 +5 超级伊昂大王 2026-03-24 5/250 2026-03-24 15:46 by 星空星月
[考研] 336化工调剂 +4 王大坦1 2026-03-23 5/250 2026-03-23 18:32 by allen-yin
[考研] 298求调剂 +8 上岸6666@ 2026-03-20 8/400 2026-03-23 11:02 by laoshidan
[考研] 285求调剂 +6 ytter 2026-03-22 6/300 2026-03-22 12:09 by 星空星月
[考研] 一志愿南大,0703化学,分数336,求调剂 +3 收到VS 2026-03-21 3/150 2026-03-21 18:42 by 学员8dgXkO
[考研] 材料学硕333求调剂 +3 北道巷 2026-03-18 3/150 2026-03-21 18:17 by 学员8dgXkO
[考研] 336求调剂 +5 rmc8866 2026-03-21 5/250 2026-03-21 17:24 by 学员8dgXkO
[基金申请] 学校已经提交到NSFC,还能修改吗? 40+4 babangida 2026-03-19 9/450 2026-03-21 16:12 by babangida
[考研] 274求调剂 +10 S.H1 2026-03-18 10/500 2026-03-20 23:51 by JourneyLucky
[考研] 一志愿南昌大学,327分,材料与化工085600 +9 Ncdx123456 2026-03-19 9/450 2026-03-20 23:41 by lovewei0727
[考研] 330求调剂 +4 小材化本科 2026-03-18 4/200 2026-03-20 23:13 by JourneyLucky
[考研] 材料学硕297已过四六级求调剂推荐 +11 adaie 2026-03-19 11/550 2026-03-20 21:30 by laoshidan
[考研] 一志愿福大288有机化学,求调剂 +3 小木虫200408204 2026-03-18 3/150 2026-03-19 13:31 by houyaoxu
信息提示
请填处理意见