حساب z-transformوتمثيل النتائج باستخدام ezpiotوتنظيم الرسوماتفي مصفوفه فرعيه باستخدام subplot

조회 수: 29 (최근 30일)
Shahed
Shahed 2025년 6월 2일
이동: Walter Roberson 2025년 6월 6일
syms n z a b
% 1. Define the time-domain functions
f1 = heaviside(n); % u(n)
f2 = a^n * heaviside(n); % a^n * u(n)
f3 = cos(a*n) * heaviside(n); % cos(an) * u(n)
f4 = sin(a*n) * heaviside(n); % sin(an) * u(n)
f5 = b^n * sin(a*n) * heaviside(n); % b^n * sin(an) * u(n)
% 2. Compute the Z-transforms
F1_Z = ztrans(f1, n, z);
F2_Z = ztrans(f2, n, z);
F3_Z = ztrans(f3, n, z);
F4_Z = ztrans(f4, n, z);
F5_Z = ztrans(f5, n, z);
% 3. Display Z-transforms in readable format
disp('F1_Z ='); pretty(F1_Z)
F1_Z = 1 1 ----- + - z - 1 2
disp('F2_Z ='); pretty(F2_Z)
F2_Z = 1 a - - ----- 2 a - z
disp('F3_Z ='); pretty(F3_Z)
F3_Z = ztrans(cos(a (n + 1)), n, z) 1 ---------------------------- + - z 2
disp('F4_Z ='); pretty(F4_Z)
F4_Z = ztrans(sin(a (n + 1)), n, z) ---------------------------- z
disp('F5_Z ='); pretty(F5_Z)
F5_Z = / z \ b ztrans| sin(a (n + 1)), n, - | \ b / -------------------------------- z
% 4. Plot using ezplot (with given a and b values)
a_val = 0.5;
b_val = 0.1;
subplot(3,2,1)
ezplot(subs(F1_Z), [0 10])
title('F1\_Z = ZT{u(n)}')
subplot(3,2,2)
ezplot(subs(F2_Z, a, a_val), [0 10])
title('F2\_Z = ZT{a^n u(n)}')
subplot(3,2,3)
ezplot(subs(F3_Z, a, a_val), [0 10])
title('F3\_Z = ZT{cos(an) u(n)}')
subplot(3,2,4)
ezplot(subs(F4_Z, a, a_val), [0 10])
title('F4\_Z = ZT{sin(an) u(n)}')
subplot(3,2,5)
ezplot(subs(F5_Z, [a b], [a_val b_val]), [0 10])
title('F5\_Z = ZT{b^n sin(an) u(n)}')
  댓글 수: 7
Walter Roberson
Walter Roberson 2025년 6월 4일
You get different results if you assume n > 0... which should cause the heaviside() call to return 1
syms n z a b
assume(n>0)
f3 = cos(a*n) * heaviside(n)
f3 = 
sympref('HeavisideAtOrigin', 0);
F3_0 = ztrans(f3, n, z);
sympref('HeavisideAtOrigin', 1/2);
F3_12 = ztrans(f3, n, z);
sympref('HeavisideAtOrigin', 1);
F3_1 = ztrans(f3, n, z);
[F3_0; F3_12; F3_1]
ans = 
Paul
Paul 2025년 6월 4일
Unclear to me how, or even if, ztrans is accounting for that assumption on n. That is, if n must be positive, then I don't know how the z-transform of f(n) = cos(a*n) is defined insofar as the z-transform sum starts at n = 0.
I would proceed with one of the following options. Maybe ztrans should do better for the latter two.
syms a n z
f(n) = cos(a*n);
ztrans(f(n))
ans = 
sympref('default');
u(n) = heaviside(n) + kroneckerDelta(n)/2;
f(n) = cos(a*n)*u(n);
ztrans(f(n))
ans = 
simplify(ans)
ans = 
sympref('HeavisideAtOrigin',1);
f(n) = cos(a*n)*heaviside(n);
ztrans(f(n))
ans = 
simplify(ans)
ans = 
However, I don't understand this:
ztrans(f(n)) % (1)
ans = 
As we saw above, that ans can be simplified. But it doesn't simplify after subtracting 1?
simplify(ans-1) % (2)
ans = 
How can (1) simplify but (2) does not?

댓글을 달려면 로그인하십시오.

답변 (1개)

Paul
Paul 2025년 6월 6일
이동: Walter Roberson 2025년 6월 6일
It does simplify after taking enough steps
sympref('HeavisideAtOrigin',1);
syms a
syms n integer
f(n) = cos(a*n)*heaviside(n);
ztrans(f(n)) % (1)
ans = 
simplify(ans-1,200)
ans = 
[num,den] = numden(ans);
num/den
ans = 

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by