help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plotting the frequency response of a filter in "real" Hz


From: Sergei Steshenko
Subject: Re: Plotting the frequency response of a filter in "real" Hz
Date: Thu, 21 Apr 2016 18:18:28 +0000 (UTC)

--------------------------------------------
On Thu, 4/21/16, Guilherme Ritter <address@hidden> wrote:

 Subject: Plotting the frequency response of a filter in "real" Hz
 To: address@hidden
 Date: Thursday, April 21, 2016, 3:44 AM
 
 Hi everyone.
 I've just started in filter design at college
 and I'm learning to use Octave for it. I want to see the
 frequency response of filters I design. I've managed to
 find code on the internet, but the output's x axis is in
 radian frequency. I'd like it to show "actual"
 Hz. For example, if the cutoff frequency is 5,5 kHz, I'd
 like for it to be represented in the plot's x axis at
 5500 or 5,5.
 I've searched a lot but couldn't find
 anything, only some solutions that work in MatLab but not in
 Octave. At college, I'm using Octave 4.0.0, packages
 control 3.0.0 and signal 1.3.2, Windows 7 Enterprise x64. At
 home, all the versions are up to date, Xubuntu 14.04
 x64.
 I've found the code 
here:https://ccrma.stanford.edu/~jos/fp/Example_LPF_Frequency_Response.html
 
 Can I use Octave's functions to get that plot
 the way I want it?
 Thanks in advance.
 -----Inline Attachment Follows-----
 
 _______________________________________________
 Help-octave mailing list
 address@hidden
 https://lists.gnu.org/mailman/listinfo/help-octave


 "the output's x axis is in radian frequency" - I guess you are talking about 
'z' domain filter.

If so, then something like this;

% code BEGIN
sample_rate = 44100; % or whatever you have
number_of_points = 1000; % the bigger number of points, the better is 
resolution of the plot
zfrequency_range = exp(pi * i * (0:number_of_points) / number_of_points); % 
from 0Hz to Nyquist frequency
semilogx(zfrequency_range(2:end), 20 * log10(abs(F(zfrequency_range(2:end))))); 
% 'F' is your filter transfer function in 'z' domain
% code END

Pay attention to "(2:end)" instead of "(1:end)", i.e. instead of default full 
index range - in 'semilogx' you can't display x of 0  because log(0) is -inf .

--Sergei.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]