Finding Z-Transform of a piecewise function.
6 views (last 30 days)
Show older comments
I am trying to find the Z-transform of the piecewise function:
using the inbuilt function ztrans().
Here is the code I wrote:
syms n z
f = piecewise(n < 0, (1/2).^(-n), n >= 0, (1/3).^(n));
Z_f = ztrans(f);
disp(Z_f);
But the command window is giving the result:
>> untitled
ztrans(piecewise(n < 0, 1/(1/2)^n, 0 <= n, (1/3)^n), n, z)
I dont know what I am doing wrong. Is there another way to do this?
0 Comments
Accepted Answer
Arnav
on 20 Sep 2024
Edited: Arnav
on 20 Sep 2024
I understand that you are trying to find the Z-Transform of a piecewise function and are not getting a simplified explicit value of the result.
You can rewrite the piecewise function using heaviside function as:
syms n z
f = (1/2).^(-n) * heaviside(-n) + (1/3).^(n) * heaviside(n); % Define the piecewise function
Z_f = ztrans(f, n, z); % Compute the Z-transform
Z_f
You may refer to the documentation of heaviside function to learn more:
Hope it helps.
More Answers (1)
Paul
on 20 Sep 2024
Based on the context of the question, it is quite likely that the problem is to solve for the bilateral z-transform of f(n). However, ztrans finds the unilateral z-transform.
To solve this problem in Matlab one has to define the f(n) as the sum of a causal signal and a non-causal signal. The z-transform of each can be found using ztrans and application of z-transform properties. Those results can be summed to find F(z) as long as their regions of convergence overlap.
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!