No BSD License  

image thumbnail

Digital implementation of RC low pass filter



31 Mar 2008 (Updated )

Plot the step and frequency response of a digital RC filter

% Creative Commons
% Attribution-Noncommercial 2.5 India
% You are free:
% to Share — to copy, distribute and transmit the work
% to Remix — to adapt the work
% Under the following conditions:
% Attribution. You must attribute the work in the manner 
% specified by the author or licensor (but not in any way 
% that suggests that they endorse you or your use of the work). 
% Noncommercial. You may not use this work for commercial purposes. 
% For any reuse or distribution, you must make clear to others the 
% license terms of this work. The best way to do this is with a 
% link to this web page.
% Any of the above conditions can be waived if you get permission 
% from the copyright holder.
% Nothing in this license impairs or restricts the author's moral rights.

% Checked for proper operation with Octave Version 3.0.0
% Author	: Krishna
% Email		:
% Version	: 1.0
% Date		: 2 December 2007
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Script for a digital implementation of RC low pass filter
close all
fsMHz = 10; % frequency, MHz
ip = [zeros(1,25) ones(1,75) zeros(1,25)]; % step input
N = 4096; % Number of points for frequency analysis 

k = 0.1;
[h1F f1] = freqz([0 k],[1 -(1-k)],N,'whole',fsMHz);
op1 = filter([0 k],[1 -(1-k)],ip);

k = 0.2;
[h2F f2] = freqz([0 k],[1 -(1-k)],N,'whole',fsMHz);
op2 = filter([0 k],[1 -(1-k)],ip);

hold on
axis([-fsMHz/2 fsMHz/2 -25 3])
grid on
xlabel('frequency, MHz')
title('Magnitude response of the filter')
legend('k=0.1', 'k=0.2') 

hold on
hold on
xlabel('time, \mus')
title('step response')
grid on
axis([0 12.4 0 1.2])
legend('ip', 'op1 k=0.1', 'op2 k=0.2')

Contact us