|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
3 t7 m- h' F# L4 a) d3 l' c5 l. {
单位样本序列$ L5 r5 U7 c6 v D2 ~: Z6 `0 {
( H1 x; ^9 S2 U+ h# P# P$ R+ g) H }
/ W( L: k. i* A! D9 H7 n p
6 F6 ?9 [6 h+ s2 B& u$ b
- clc
- clear
- close all
- n1 = 0;
- n2 = 5;
- n0 = 3;
- n = [n1:n2];
- x = [(n - n0) == 0];
- stem(n,x,'filled');
- ylim([-1,2]);/ x6 l ~& r; p; l+ r( x2 ^
' k/ ~4 f7 K6 C7 x* W# J
* D+ |% x A& o" B7 @) o1 }- I
, O% q% `! J0 i! e9 f( `8 p
改成一个函数:
) M! u; F7 x! U1 C4 r
' I# W2 D& I# `6 V- function [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]; t! o, ]; R5 W& S y: l, F( y' m+ e- J
9 l5 f5 e) U6 M( U" Z命名为delta.m# E3 z7 p+ C/ W) a% |$ q
. E7 J5 f% e1 x3 C
新建一个脚本:
& R0 R" g) `: m( U$ W# S/ ~$ Y- z6 f/ G8 a9 _* [" r6 y' @
- n0 = 3;
- n1 = -3;
- n2 = 6;
- [x,n] = delta(n0,n1,n2);
- stem(n,x,'filled');
- ylim([-1,2]);6 C+ ^# J" f$ D; Y7 ~. w0 }
9 a' b# M, \$ s' F# q$ z运行得到:
. Z, l2 E+ n2 R/ W
1 B: ~# o6 S4 W* i, O" z _, F
1 e6 }! Y2 }" W z3 x Y
; Q9 c% n! Q! w3 a5 b
+ Y3 x$ b5 P# s$ m单位阶跃序列2 z. Q& l2 [' ] D
+ R) r. ?. |4 [5 x/ O- G& B# V# E
1 t$ ]( f3 P9 W" o5 Q" Y. \+ O0 x% k2 K) m+ g
直接写成函数形式吧:7 i8 t5 m+ }( C* r; Q0 T
# s% q. b% r8 c+ z$ ?- function [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];
! g2 K- A; r. n# o 6 _3 {6 k1 `/ M- B/ W( U/ X
新建一个脚本,测试:
; [# {6 Y+ o7 M. ]7 ]( H2 W% f A/ W3 l5 J" `- C; Q9 H
- clc
- clear
- close all
- n0 = 3;
- n1 = -3;
- n2 = 6;
- [x,n] = stepseq(n0,n1,n2);
- stem(n,x,'filled');
- ylim([-1,2]);# u" o9 @2 K# ], O/ b# O7 Z
v1 r2 i7 T8 `' {结果:
N' x2 f6 y) o$ V- x
+ i0 J. {8 t* P0 j: H! n
5 m& l3 N' X) Y7 A/ L
6 X' C$ K' e7 T) @, s
% M6 \* I1 [2 U& a1 T7 y2 C实值指数序列
5 @9 `8 F$ |9 O, N# B
4 S" t4 z" ]! R( S0 j
为一般形式。+ H& m5 o3 s5 f' \
; P8 h* |1 {7 Z
下面产生一个序列:
3 \: g4 E0 H$ \- ?6 x+ G/ ?5 |, H( ^- _( [9 w% G% v7 w
) u+ p- ]1 A; Q& Q) A0 B) l# M+ Y" x; K$ L. h% c
脚本代码:
1 B. u2 K4 p" G1 t% D/ L& V2 D$ I0 l; h f7 t. G! q6 q
- clc
- clear
- close all
- n = -3:10;
- x = 0.9.^n;
- stem(n,x,'filled');
- xlabel('n');
- ylabel('0.9^n');
- xlim([-5,13]);
- ylim([0,2]);
& r P4 Q# e% d' Z' k( }! p+ k
! R6 C* E4 ?* P/ j2 R6 k
5 f: Q/ C; r! \$ V
2 F+ F* ]0 z& B/ L0 c9 l0 f1 I" z
9 t t1 y$ [/ ^' b$ d1 T* _复指数序列
- B0 h0 y% Z" Q/ U5 a7 `: h7 x8 G4 L' ]- i/ Z, |. `
" `: k2 h( ?. s8 T) i) \
/ G1 O3 F2 U3 t3 Q/ V- clc
- clear
- close all
- n = 0:10;
- x = exp( (2+3j)*n );
- stem(n,x);
- xlabel('n');
, y# H6 q- p- t. i9 t1 R
# W5 k) l2 W4 o( J6 U
i S' }9 C1 j" K1 Q7 \4 d) g6 Z |1 l7 ]0 h
; T& r4 L" M, f2 K' R A* _
周期序列+ f3 d8 E& A8 d
7 k% @# N: Z) U3 ^) Q
- clc
- clear
- close all
- n = 0:10;
- x = exp( (2+3j)*n );
- subplot(2,1,1)
- stem(n,x);
- xlabel('n');
- title('Not Period Sequence');
- % the number of period
- P = 5;
- xtilde = x' * ones(1,P);
- xtilde = xtilde(:)';
- subplot(2,1,2);
- stem(xtilde);
- title('Period Sequence');0 j# F8 ^ T2 o, z
9 d- y8 a% t3 b
. b1 R5 [( C) W+ i" X* j7 m9 B" \/ c: W) Z1 d# @: Y
: s5 P/ h7 {& j8 l |
|