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: Guilherme Ritter
Subject: Re: Plotting the frequency response of a filter in "real" Hz
Date: Fri, 22 Apr 2016 19:39:59 -0300

2016-04-22 19:26 GMT-03:00 Guilherme Ritter <address@hidden>:
> @ Sergei Steshenko
>
> 2016-04-22 16:16 GMT-03:00 Maynard Wright <address@hidden>:
>>> --//--
>>>
>>> @ Maynard Wright
>>>
>>> That just makes the x axis be between 0 and 0,5. Not what I'm looking
>>> for. I'm looking for Hz in the audio range.
>>>
>>
>> Here's an example with plots which is probably not appropriate to post to the
>> full list as I think that the attached figures would be stripped away anyway.
>>
>> I think, and I could be wrong, that what you have is a function that produces
>> a filter response in terms of the radian frequency and you would like to plot
>> the same result in terms of the frequency in Hz.   If that's so, the code
>> below will do that.   I've included a trivial filter as an example.   The 
>> code,
>> as is, will plot the amplitude function of the filter as a function of the
>> radian frequency.
>>
>> If you uncomment the commented lines and comment out the lines associated 
>> with
>> the radian frequency, you will get a plot of the same function in terms of 
>> the
>> frequency in Hz.
>>
>> Note that the function is not recalculated.   It is simply plotted against a
>> scaled x-axis function.
>>
>> I use gnuplot because it's easier to work with when you use screen capture 
>> but
>> you don't have to do that.
>>
>>
>> graphics_toolkit("gnuplot");
>> w = linspace(1, 15000, 100);
>> fHz = w / (2 * pi);
>> loss = abs((12000 ./ (12000 .+ 1j .* w)) .^ 7);
>> loglog(w, loss);
>> % loglog(fHz, loss);
>> axis([1e-1, 1e5, 2e-2, 2]);
>> xlabel("radian frequency");
>> % axis([1e-1, 1e4, 2e-2, 2]);
>> % xlabel("frequency in Hz");
>> ylabel("amplitude");
>> grid;
>> pause;
>>
>>
>> Best regards,
>>
>>
>> Maynard Wright
>>

Ignore the last message...

@ Sergei Steshenko

I'm sorry, but I was tired from working on this the whole day and
didn't posted all of the error messages. Here they are:

error: freqresp: second argument 'w' must be a real-valued vector of frequencies
error: called from
    freqresp at line 52 column 5
    subsref at line 39 column 13
    frequency_response at line 24 column 1
error: evaluating argument list element number 1
error: called from
    frequency_response at line 24 column 1
error: evaluating argument list element number 1
error: called from
    frequency_response at line 24 column 1
error: evaluating argument list element number 2
error: called from
    frequency_response at line 24 column 1

frequency_response.m is the file that contains the code I posted
earlier, although the last line here is line 25 there. Neither you nor
I used "freqresp", but it's mentioned in the error messages.

Also, I read the help for the "butter" function, and I noticed it
should generate output in Z space, but I suspected I had to transform
it for two reasons: 1) the output of "tf", when printed, uses "s"
instead of "z" and 2) "tf" have parameters to generate output in "z"
space, but the function fails when I try to use these functionalities.

@ Maynard Wright

I should have been more specific when I said I had just started in
filter desing. This is a course for a Computer Engineering degree.
Which means that I will deal with filter design until 18th of May, and
then I'll probably forget about it for the rest of my life. While this
course is provided by an Electric Engineering teacher, since we don't
have any Electric Engineering students this semester, our teacher have
encouraged us to stick to the built in functions to solve problems and
we barely scratched the surface of the mathematics involved.

Having said that, I have no idea where is the filter in the code you posted.



reply via email to

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