|  | 
 
| 
x
EDA365欢迎您登录!您需要 登录 才可以下载或查看,没有帐号?注册  - |1 c( P) E( J  ^单位样本序列
 $ j8 m% H2 Z/ r' e
 5 H* ?6 V  ~# l' B6 s3 m( S
  & h6 y* ~. I) g% X' b 
 4 ^" P; M5 [" b1 d' D4 t$ r) J
 clcclearclose alln1 = 0;n2 = 5;n0 = 3;n = [n1:n2];x = [(n - n0) == 0];stem(n,x,'filled');ylim([-1,2]);5 }7 B- h5 Z  J( ^" Z' p
 / S* [, R! i; h! b- a5 w) d
  1 Z* s  X! V0 p 9 b3 i/ O  ~9 |2 [6 @, y' G
 改成一个函数:
 # I$ m6 U( `1 U- r" R1 Q% g0 h# c% `/ w, M, F; i+ i; Z, I/ J( `; p
 
 ! {, l0 Y3 h* j6 _5 Q$ Kfunction [x,n]=delta(n0,n1,n2);% generate x(n) = delta(n - n0); n1 <= n <= n2%_____________________________________________%[x,n] = delta(n0, n1, n2);%n = [n1:n2];x = [(n-n0) == 0];3 _: N* f( m. @; l. ~. j1 i7 O( j
 命名为delta.m7 C0 Q9 u  B( v' [4 [' N
 
 ; _; \* @4 ~7 U% V新建一个脚本:
 0 J$ W$ t% P2 x& g# @/ y, F4 ?9 A& ?, `' _+ X, }2 h
 
 5 C# ^0 |7 y' m0 ?* T5 c, D5 F$ O. ^n0 = 3;n1 = -3;n2 = 6;[x,n] = delta(n0,n1,n2);stem(n,x,'filled');ylim([-1,2]);6 s$ y3 j9 r& r; ^" y/ t& E. V
 运行得到:) v. y6 v+ e1 C2 w
 
 ) R  Z  |8 p# C
  3 R+ m$ n+ p* @+ |. T4 F  c0 U 
 $ i  @$ B& u# S% N
 4 a1 J: e. D- U单位阶跃序列
 ' f9 d! O2 w( c5 {, H
 - N3 y/ B, @5 g. ^1 x
   % \( w6 J6 y$ ~1 j5 d; p# I9 y+ g  {* }9 U) C% ]
 直接写成函数形式吧:: Q, c$ I' c  A
 . f. J  }- n1 m3 W; ?
 
 ) i8 l1 X4 W7 t+ o  p8 I- tfunction [x,n]=stepseq(n0,n1,n2);% generate x(n) = u(n - n0); n1 <= n <= n2%_____________________________________________%[x,n] = stepseq(n0, n1, n2);%n = [n1:n2];x = [(n-n0) >= 0];7 i, ]0 V6 i6 B0 U
 新建一个脚本,测试:3 M0 \1 S/ @1 f- ]  L
 ! k; c+ f! Q0 Q% X
 
 1 }$ ]  e. W: E0 q+ {; r: Aclcclearclose alln0 = 3;n1 = -3;n2 = 6;[x,n] = stepseq(n0,n1,n2);stem(n,x,'filled');ylim([-1,2]);) m+ s7 ~3 X1 r, T5 d9 L
 结果:
 $ |- J4 U3 `; A" k) T6 _& V* Q' g( ^, q2 A3 z$ H* F" X$ D
 
   4 M  }) f+ t& Q: V
 4 ?3 o' i7 P' u  s5 r: @* t8 ]  g- l: L/ H$ g& b) t2 t  f1 x& o
 实值指数序列) {1 k  z# N( {1 ~* T7 e
 
 ) @) I* c3 e9 m- i( }0 \: p$ X3 z' M: }
  为一般形式。 : @) a% E' l' e- ^2 p' @- ~; y5 A4 K  {7 M$ i
 下面产生一个序列:2 @! L; X  r# H) P5 C6 I
 , D; E6 l6 Y- n$ [  U4 F
 
  1 s+ @1 U0 m" I2 V6 ]( P 
 + W+ H% C& X( D$ ?! d; K$ e. t8 L脚本代码:: T: [5 ~, r; r  @0 ]. W
 
 8 a; t+ T1 N  H( E( s1 B! u
 clcclearclose alln = -3:10;x = 0.9.^n;stem(n,x,'filled');xlabel('n');ylabel('0.9^n');xlim([-5,13]);ylim([0,2]);1 q, o1 ~& C' Z6 b2 B1 o
 " i3 B7 c: w+ o$ b
  Y% P: M$ A' Y+ Z - l8 A/ ?; e5 b2 `+ U1 B& b* ~* Y
 + P  w* A6 x2 a9 y- B& j! c& j
 复指数序列( H) \7 v  i) `. p) Z6 B9 D% C
 
 : F' x7 q* W5 B
   9 u  H% d+ v! a5 H' ]1 l% K0 c$ j4 w4 y0 c; Q9 _
 
 clcclearclose alln = 0:10;x = exp( (2+3j)*n );stem(n,x);xlabel('n');- N4 _0 a" a( R
 0 z' S0 j2 @7 V0 R7 j7 I% m
  2 L- k2 T! C; V# r ! Y% B7 D( u" N3 T2 S
 ) H2 I5 s, B. A; y& D% Q+ C# N
 周期序列
 & @8 b/ }# b& B: m% @+ D/ l& }
 6 a2 Y; H1 d, a0 `
 clcclearclose alln = 0:10;x = exp( (2+3j)*n );subplot(2,1,1)stem(n,x);xlabel('n');title('Not Period Sequence');% the number of periodP = 5;xtilde = x' * ones(1,P);xtilde = xtilde(:)';subplot(2,1,2);stem(xtilde);title('Period Sequence');* O/ M, ^8 Y8 b/ n; ~
 0 o: v1 Y/ T4 w7 \
  6 E* k1 H) m! k 7 n9 _. |  V& J- U" I! g1 O
 
 / C! k) |& a8 K% q( f
 | 
 |