Having issues getting magnitude frequency response for a Difference equation
이전 댓글 표시
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개)
nick
2023년 11월 23일
0 개 추천
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
카테고리
도움말 센터 및 File Exchange에서 Analog Filters에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!