Having issues getting magnitude frequency response for a Difference equation

4 visualizaciones (últimos 30 días)
I'm having trouble with an asignment (I started using Matlab a day ago) in which I need to get the magnitude of a difference equation as well as get the unit impulse response and store it in an array.
After some time looking online, and teaching myself how to do the z-transform, I managed to get this as my code:
% Difference equation -> y(n) = 0.2*x(n) + 0.34*x(n-10)
%Transform to z-plane -> H(z) = Y(z)/X(z) = 0.2 + 0.34z^-10
A = [0.2 0 0 0 0 0 0 0 0 0 0.34];
B = 1;
% Creates the transform function and plots magnitude/phase
H = filt(A,B);
figure;
bode(H);
% Plots unit impulse response
figure;
impulse(H);
The only probelm is that it isn't what my professor is looking for nor would he give an indication of what to do. I can't seem to find any documents online to help me with the problem, I'm not sure what it would fall under, however I think that I need to use the frequency response function? Any help would be much appreciated.
  1 comentario
Bernardo Rodriguez Jr
Bernardo Rodriguez Jr el 29 de Abr. de 2022
Update
I'm currently attempting this for the magnitude, but i'm still unsure if it is correct:
j = sqrt(-1);
w = linspace(-pi, pi);
H = 0.2 - 0.34*exp(-j*10*w);
figure;
stem(abs(H));

Iniciar sesión para comentar.

Respuestas (1)

nick
nick el 23 de Nov. de 2023
Hi Bernardo,
I understand from your query that you want to obtain the magnitude and impulse response of the difference equation.
I am assuming the given difference equation is a discrete time equation as you have used Z-transform. Thus, you are working with digital filters. You must use 'freqz' instead of 'bode' to obtain the frequency response, phase and magnitude, of digital filters. You may refer the following documentation of 'freqz' to learn more about it :
Similarly, you must use 'impz' instead of 'impulse' to obtain impulse response of digital filters. You may refer the following documentation to learn more about 'impz':
Hope this helps,
Regards,
Neelanshu

Categorías

Más información sobre Time and Frequency Domain Analysis en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by