Finding Z-Transform of a piecewise function.

18 次查看(过去 30 天)
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?

采纳的回答

Arnav
Arnav 2024-9-20
编辑:Arnav 2024-9-20
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.

更多回答(1 个)

Paul
Paul 2024-9-20
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.

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by