Inverse Z Transform recursion code not working?

2 visualizaciones (últimos 30 días)
Joel Okanta
Joel Okanta el 12 de Abr. de 2021
Respondida: Shadaab Siddiqie el 15 de Abr. de 2021
So I was working on this code that basically uses the power series to use recursion to do an inverse Z transform from a given function. ~
syms a b i n x z % Create symbolic variables
prompt = 'What is the value of n? ';
x_n = input(prompt)
x_n = (a*n - symsum(x*(n-i))*b*i/b);
x_n=simplify(x_n)
g=iztrans(x_n,z,n); %Inverse Z-transform for xn[z]
g=simplify(g)
Fs = 100; % Sampling frequency
T = (1 / Fs)*pi; % Sampling period (time interval between samples)
L = 10*pi; % Length of signal duration in seconds
t= (0:T:(L-T)); % Time interval set
g=subs(g,n,t); %Substitute the values of t into the double value h
figure(1); % Open a new figure
stem(t,g) % Plot the transfer function
hold on
h2=sin(pi.*t/3);
stem(t,(h2))
hold off
xlabel('t / s');
ylabel('h(t)');
However, when running the code, it outputted this:

Respuestas (1)

Shadaab Siddiqie
Shadaab Siddiqie el 15 de Abr. de 2021
From my understanding you are getting an error for the above code. This is because you are substituting the n with t, in line
g=subs(g,n,t); %Substitute the values of t into the double value h
but still g here has another variable x which is not assigned to any value before your plot it in line
stem(t,g) % Plot the transfer function
therefore, you are getting an error. Please refer syms and subs for more information.

Community Treasure Hunt

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

Start Hunting!

Translated by