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

29 visualizzazioni (ultimi 30 giorni)
Shahed
Shahed il 2 Giu 2025
Spostato: Walter Roberson il 6 Giu 2025
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 Commenti
Walter Roberson
Walter Roberson il 4 Giu 2025
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 il 4 Giu 2025
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?

Accedi per commentare.

Risposte (1)

Paul
Paul il 6 Giu 2025
Spostato: Walter Roberson il 6 Giu 2025
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 = 

Tag

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by