matlab cos sinx,matlab求y=sinxcos(2x)及其包络线急!!!

提取包络线程序 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, , 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); ==================== 上叙文件存为.m文件 命令窗口输入 x=-2*pi:0.02:2*pi; y=sin(x)*cos(2*x); [up,down]=envelope(x,y,'linear'); plot(x,y,'k-*',x,up,'r.-');hold on; plot(x,down,'b.-');

作业帮用户

2016-11-26

举报

6c0a0adef10d1043fa4f41a7897345ed.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值