⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perext.m

📁 很多matlab的源代码
💻 M
字号:
function y = perext(x,n,ty)
% PEREXT Periodic extension of a signal.
%
%       Y = PEREXT(X,P,OPT) generates periodic extension (PE) of X
%	P=is a 2 element vector [T ts]=[period sampling interval]. Def. ts=1
%       OPT=1 assumes X is the rightsided part of an even function 
%	Y is the periodic extension with length N=fix(T/ts).
%
%       PEREXT (with no input arguments) invokes the following example:
%
%       % Approximate the PE of exp(-t) with T=2 and plot for 3 periods.
%         >>ts=0.01;t=(0:599)*ts;xn=exp(-t);perext(xn,[2 ts]);
%	  >>plot(t,xn,t,[xp xp xp])


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,help perext,disp('Strike a key to see results of the example')
pause,ts=0.01;t=(0:599)*ts;xn=exp(-t);xp=perext(xn,[2 ts]);
 v=matverch;
 if v < 4, eval('clg');else,eval('clf');end

plot(t,xn,t,[xp xp xp]),grid,return,end

if nargin<3,ty=0;end

[mm,nn]=size(x);if mm~=1,x=x.';end
if length(n)==1,n=n(1);else,n=fix(n(1)/n(2));end
y=zeros(1,n);m=length(x);k=fix(m/n);r=rem(m,n);
if r>0,x=[x zeros(1,n-r)];k=k+1;end
if ty==1,x=[x 0];end
for j=1:k,y=y+x(1:n);
if ty==1,y=y+x(n+1:-1:2);end
x(1:n)=[];end
if mm~=1, y=y.';end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -