Frequency response function In matlab

조회 수: 13 (최근 30일)
shabaz lee
shabaz lee 2018년 2월 20일
답변: Walter Roberson 2018년 2월 20일
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