Frequency response function In matlab

14 次查看(过去 30 天)
Can someone help me with this matlab frequency response problem.
This is what I have so far, but code doesnt work.
function [H] = freqresp(b, a, w)
a(1) = 1;
numer(0) = 0;
denom(1) = 0;
for k=1:length(b)
numer(k) = numer(k-1) + b(k) * exp(i*w*k);
end
for m=2:length(a)
denom(m) = denom(m-1) + a(m)*exp(i*w*k);
end
H = numer/denom;

回答(1 个)

Walter Roberson
Walter Roberson 2018-2-20
You have
numer(0) = 0;
In MATLAB, indexing can never start from 0. You need
numer(1) = 0;
for k=1:length(b)
numer(k+1) = numer(k) + b(k) * exp(i*w*k);
end
for m=1:length(a)
denom(m+1) = denom(m) + a(k)*exp(i*w*k);
end
But after that you have a problem. You could try
H = numer ./ denom
but if length(a) and length(b) are not the same, you have a problem.

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by