[Scilab-users] Frequency response

Rafael Guerra jrafaelbguerra at hotmail.com
Sat Sep 15 22:47:07 CEST 2018


Forgetting MATLAB for a second, can you define your problem ?

How is your specific frequency response defined? In Laplace, Fourier, z-transform, ..., domain?
________________________________
From: users <users-bounces at lists.scilab.org> on behalf of Claus Futtrup <cfuttrup at gmail.com>
Sent: Saturday, September 15, 2018 11:15:08 PM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] Frequency response

Hi Samuel and Scilabers

My problem with freq and repfreq is that they require a "sys" input, which implies I need to describe a response function of some sort. For example (from the Scilab web-help):

https://help.scilab.org/docs/6.0.1/en_US/freq.html (example code)

s=poly<https://help.scilab.org/docs/6.0.1/en_US/poly.html>(0,'s');
sys=(s+1)/(s^3-5*s+4)
rep=freq(sys("num"),sys("den"),[0,0.9,1.1,2,3,10,20])



https://help.scilab.org/docs/6.0.1/en_US/repfreq.html (syntax)

[ [frq,] repf]=repfreq(sys,fmin,fmax [,step])
[ [frq,] repf]=repfreq(sys [,frq])
[ frq,repf,splitf]=repfreq(sys,fmin,fmax [,step])
[ frq,repf,splitf]=repfreq(sys [,frq])

... So, the thing with the matlab freqz (as the example repeated below shows) is just a basic FFT with sampling, etc:

h = rand(1,64); // impulse response (Matlab source code)
fs = 1000;
Nfft = 128;
[H,F] = freqz(h,1,Nfft,fs);
semilogx(F,mag2db(abs(H))); grid on;
xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)');

It may very well be that I just don't understand the help page of repfreq. For example it says about sys: "A siso or simo linear dynamical system, in state space, transfer function or zpk representations, in continuous or discrete time." - al right then, it seems pretty capable, but so, what's "zpk" for example? ... my apologies for finding the Scilab help to be cryptic and the examples insufficient for me to solve my problem, hence I ask if someone can take above matlab code and make it work in Scilab.

Best regards,
Claus

On 15.09.2018 00:32, Samuel Gougeon wrote:
Le 14/09/2018 à 20:57, Claus Futtrup a écrit :

Dear Scilabers

I have calculated an impulse response and wish to do an FFT to achieve the frequency response. I know what to expect. In the matlab forum someone asked the same question and was recommended to use freqz ... I wonder what would be the equivalent function in Scilab?

https://www.mathworks.com/matlabcentral/answers/350350-how-to-plot-loudspeaker-frequency-response-from-its-impulse-response

For example, to replicate the code snippet (second answer in above link), how to do this in Scilab?

h = rand(1,64); // impulse response (Matlab source code)
fs = 1000;
Nfft = 128;
[H,F] = freqz(h,1,Nfft,fs);

Did you have a look around freq() or repfreq()?

We have somewhat the equivalence invfreqz(H,F,m,n,W)  <=>  frfit(F*2*%pi, H, n, W) // Scilab

So you may look for the reciprocal of Scilab's frfit()

HTH
Samuel




_______________________________________________
users mailing list
users at lists.scilab.org<mailto:users at lists.scilab.org>
http://lists.scilab.org/mailman/listinfo/users



[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>      Virus-free. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180915/94771bcc/attachment.htm>


More information about the users mailing list