f3 = 
حساب z-transformوتمثيل النتائج باستخدام ezpiotوتنظيم الرسوماتفي مصفوفه فرعيه باستخدام subplot
Afficher commentaires plus anciens
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)
disp('F2_Z ='); pretty(F2_Z)
disp('F3_Z ='); pretty(F3_Z)
disp('F4_Z ='); pretty(F4_Z)
disp('F5_Z ='); pretty(F5_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 commentaires
Walter Roberson
le 2 Juin 2025
Approximate translation:
Calculate z-transform, plot results using ezpiot, and organize graphs into a subarray using subplot.
Les Beckham
le 3 Juin 2025
It looks like OP has already done just that.
@Shahed: Do you have a question?
Walter Roberson
le 3 Juin 2025
I notice that the ztrans for F3, F4, and F5 all use the indeterminate form ztrans() instead of particular calculations. @Shahed might be asking about that part, perhaps.
syms n z a b
f3 = cos(a*n) * heaviside(n)
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]
so the results are all the same, except with the HeavisideAtOrigin added as a constant.
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)
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]
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))
sympref('default');
u(n) = heaviside(n) + kroneckerDelta(n)/2;
f(n) = cos(a*n)*u(n);
ztrans(f(n))
simplify(ans)
sympref('HeavisideAtOrigin',1);
f(n) = cos(a*n)*heaviside(n);
ztrans(f(n))
simplify(ans)
However, I don't understand this:
ztrans(f(n)) % (1)
As we saw above, that ans can be simplified. But it doesn't simplify after subtracting 1?
simplify(ans-1) % (2)
How can (1) simplify but (2) does not?
Réponses (1)
Paul
le 6 Juin 2025
Déplacé(e) : Walter Roberson
le 6 Juin 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)
simplify(ans-1,200)
[num,den] = numden(ans);
num/den
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!












