Plotting IIR filter error

3 ビュー (過去 30 日間)
Nathan Jaqua
Nathan Jaqua 2019 年 11 月 2 日
回答済み: Star Strider 2019 年 11 月 2 日
I have an IIR filter I am trying to plot, but I am not sure what I am doing wrong here. Can someone please help?
My code:
%% This is a first part of an exercise.
% Here you are implementing the transfer function H(z).
% Pass different values of theta and r to have differnt outcome.
clc; clear all;
%% Part -1 simulation
% initialize r
r = 0.99 ;
%initialize theta
theta = pi/3 ;
% initialize omega vector. Let, ω to start from 0 to pi with % 200 intermediate values.
w = 200 ;
% Now, define z = e^(j*w).
z = exp(1i*w);
% implement H
H = 1./(1 - (2*r*cos(theta)*(z.^-1))+((r^2)*(z.^-2)));
% Now, plot the filter magnitude response in dB scale w.r.t w.
figure;plot(w, );grid on;
xlabel('normalized frequency'); ylabel('amplitude in dB')
title('Frequency and phase response at r = and theta = ');
  2 件のコメント
Star Strider
Star Strider 2019 年 11 月 2 日
What result are you supposed to get, and what result are you getting?
Nathan Jaqua
Nathan Jaqua 2019 年 11 月 2 日
I have not even been able to get anything to show up in the plot. I need it to plot properly.

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2019 年 11 月 2 日
You are plotting one point, so you need to plot a marker instead of a line.
I am not certain what you are doing, so consider this example:
% Now, define z = e^(j*w).
z = @(w) exp(1i*w);
% implement H
H = @(w) 1./(1 - (2*r*cos(theta)*(z(w).^-1))+((r^2)*(z(w).^-2)));
% Now, plot the filter magnitude response in dB scale w.r.t w.
w = linspace(-100*pi, 100*pi, 250);
figure;plot(w, abs(H(w)));grid on;
xlabel('normalized frequency'); ylabel('amplitude in dB')
title('Frequency and phase response at r = and theta = ');
Experiment to get the result you want.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFilter Design についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by