[Scilab-users] Frequency response

Rafael Guerra jrafaelbguerra at hotmail.com
Sun Sep 16 19:27:36 CEST 2018


Hi Claus,

In your script, the response function resp(s) is definitely not a simple LTI system, not even a ratio of polynomials, because of the logarithmic term.
I am not an expert but I suspect that such highly non-linear transfer functions are not handled by the standard Scilab DSP tools such as syslin, etc.

I do not see how you can "close the loop", other that testing your theoretical model against experimental data?

PS:
ZPK Zero pole gain system representation: zeros Z, poles P, and gain(s) K.

Regards,
Rafael

From: users <users-bounces at lists.scilab.org> On Behalf Of Claus Futtrup
Sent: Sunday, September 16, 2018 5:49 PM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] Frequency response

Hi Rafael

My problem is defined as a response function, where I use contour integral to achieve the step response. Then I differentiate it to achieve the impulse response. In essense I already "know" my response function. It contains some special features (it could for example be a logarithmic term) and e.g. "syslin" or "bode" will choke on it. If I already know the response function, why bother with the FFT? Well, I'd like to ensure the time response and frequency response are correct (without errors on my part) and one way of verifying is to close-the-loop and calculate the FFT, see that input = output. I'd like to verify that the absolute levels are correct.

Attached please find the script (10 kb). It's fully functional. Apologies for the comments in the script, I didn't clean it up for publishing...

Best regards,
Claus

On 15.09.2018 22:47, Rafael Guerra wrote:
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><mailto:users-bounces at lists.scilab.org> on behalf of Claus Futtrup <cfuttrup at gmail.com><mailto:cfuttrup at gmail.com>
Sent: Saturday, September 15, 2018 11:15:08 PM
To: users at lists.scilab.org<mailto: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>





_______________________________________________

users mailing list

users at lists.scilab.org<mailto:users at lists.scilab.org>

http://lists.scilab.org/mailman/listinfo/users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180916/3a1ef6cc/attachment.htm>


More information about the users mailing list