0% found this document useful (0 votes)
15 views3 pages

Z-Transform and Inverse Computation

The document outlines a MATLAB script for computing the Z-transform and its inverse for a user-defined discrete-time signal. It prompts the user to input a sequence, calculates the Z-transform using a loop, and displays both the Z-transform and its inverse. The script also includes a specific example of computing the Z-transform for the sequence defined as a^n.

Uploaded by

charvigupta3005
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Z-Transform and Inverse Computation

The document outlines a MATLAB script for computing the Z-transform and its inverse for a user-defined discrete-time signal. It prompts the user to input a sequence, calculates the Z-transform using a loop, and displays both the Z-transform and its inverse. The script also includes a specific example of computing the Z-transform for the sequence defined as a^n.

Uploaded by

charvigupta3005
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

clc; clear; close all; % ---- INVERSE Z-TRANSFORM

syms Z n a COMPUTATION ----


x_n = sym(zeros(1, N));
disp('221220031 Z and Inverse Z
Transform') for i = 1:N
x_n(i) = X_z(i)*Z^(i-1);
% User input for the discrete-time end
signal
x = input('Enter the discrete-time disp('Inverse Z-transform sequence
sequence x[n] as a vector (e.g., [1 2 x[n]:');
3 4]): '); disp(x_n);

% Define index range (assuming % ---- COMPUTE Z-TRANSFORM OF a^n ---


starting from n=0) -
N = length(x); % Number of elements x_n2 = 0.5^n; % Define x[n] = a^n
n_values = 0:N-1; % Time indices
% Compute Z-transform using built-in
% ---- Z-TRANSFORM COMPUTATION ---- function
X_z = sym(zeros(1, N)); % Initialize X_z2 = ztrans(x_n2, n, Z); % Use
symbolic array for Z-transform correct variable order (n → Z)
disp('Z-transform of a^n:');
% Compute Z-transform using loop disp(X_z2);
for i = 1:N
X_z(i) = x(i) * Z^(-(i-1)); % Compute Inverse Z-transform
end x_inv = iztrans(X_z2, Z, n); %
Ensure proper variable order
% Sum all terms
X_z_final = sum(X_z);

disp('Z-transform of x[n]:'); disp('Inverse Z-transform:');


disp(X_z_final); disp(x_inv);
clc; clear; close all; % ---- INVERSE Z-TRANSFORM
syms Z n a COMPUTATION ----
x_n = sym(zeros(1, N));
disp('221220024 Z and Inverse Z
Transform') for i = 1:N
x_n(i) = X_z(i)*Z^(i-1);
% User input for the discrete-time end
signal
x = input('Enter the discrete-time disp('Inverse Z-transform sequence
sequence x[n] as a vector (e.g., [1 2 x[n]:');
3 4]): '); disp(x_n);

% Define index range (assuming % ---- COMPUTE Z-TRANSFORM OF a^n ---


starting from n=0) -
N = length(x); % Number of elements x_n2 = 0.5^n; % Define x[n] = a^n
n_values = 0:N-1; % Time indices
% Compute Z-transform using built-in
% ---- Z-TRANSFORM COMPUTATION ---- function
X_z = sym(zeros(1, N)); % Initialize X_z2 = ztrans(x_n2, n, Z); % Use
symbolic array for Z-transform correct variable order (n → Z)
disp('Z-transform of a^n:');
% Compute Z-transform using loop disp(X_z2);
for i = 1:N
X_z(i) = x(i) * Z^(-(i-1)); % Compute Inverse Z-transform
end x_inv = iztrans(X_z2, Z, n); %
Ensure proper variable order
% Sum all terms
X_z_final = sum(X_z);

disp('Z-transform of x[n]:'); disp('Inverse Z-transform:');


disp(X_z_final); disp(x_inv);
clc; clear; close all; % ---- INVERSE Z-TRANSFORM
syms Z n a COMPUTATION ----
x_n = sym(zeros(1, N));
disp('221220005 Z and Inverse Z
Transform') for i = 1:N
x_n(i) = X_z(i)*Z^(i-1);
% User input for the discrete-time end
signal
x = input('Enter the discrete-time disp('Inverse Z-transform sequence
sequence x[n] as a vector (e.g., [1 2 x[n]:');
3 4]): '); disp(x_n);

% Define index range (assuming % ---- COMPUTE Z-TRANSFORM OF a^n ---


starting from n=0) -
N = length(x); % Number of elements x_n2 = 0.5^n; % Define x[n] = a^n
n_values = 0:N-1; % Time indices
% Compute Z-transform using built-in
% ---- Z-TRANSFORM COMPUTATION ---- function
X_z = sym(zeros(1, N)); % Initialize X_z2 = ztrans(x_n2, n, Z); % Use
symbolic array for Z-transform correct variable order (n → Z)
disp('Z-transform of a^n:');
% Compute Z-transform using loop disp(X_z2);
for i = 1:N
X_z(i) = x(i) * Z^(-(i-1)); % Compute Inverse Z-transform
end x_inv = iztrans(X_z2, Z, n); %
Ensure proper variable order
% Sum all terms
X_z_final = sum(X_z);

disp('Z-transform of x[n]:'); disp('Inverse Z-transform:');


disp(X_z_final); disp(x_inv);

You might also like