<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta content="text/html; charset=Windows-1252">
</head>
<body bgcolor="#FFFFFF">
<div dir="auto" style="direction:ltr; margin:0; padding:0; font-family:sans-serif; font-size:11pt; color:black">
Forgetting MATLAB for a second, can you define your problem ?<br>
<br>
</div>
<div dir="auto" style="direction:ltr; margin:0; padding:0; font-family:sans-serif; font-size:11pt; color:black">
How is your specific frequency response defined? In Laplace, Fourier, z-transform, ..., domain?</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> users <users-bounces@lists.scilab.org> on behalf of Claus Futtrup <cfuttrup@gmail.com><br>
<b>Sent:</b> Saturday, September 15, 2018 11:15:08 PM<br>
<b>To:</b> users@lists.scilab.org<br>
<b>Subject:</b> Re: [Scilab-users] Frequency response</font>
<div> </div>
</div>
<div>
<div class="moz-cite-prefix">Hi Samuel and Scilabers<br>
<br>
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):<br>
<br>
<a class="moz-txt-link-freetext" href="https://help.scilab.org/docs/6.0.1/en_US/freq.html">https://help.scilab.org/docs/6.0.1/en_US/freq.html</a> (example code)<br>
<pre class="scilabcode" style="margin-bottom:0px; margin-top:0px; overflow-x:auto; width:728.094px; word-wrap:break-word; color:rgb(51,51,51); font-style:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px"><span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">s</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">=</span><a class="scilabcommand" href="https://help.scilab.org/docs/6.0.1/en_US/poly.html" style="color:rgb(50,185,185); text-decoration:underline; font-style:normal">poly</a><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">(</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">0</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">'</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">s</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">'</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">)</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">;</span>
<span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">=</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">(</span><span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">s</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">+</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">1</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">)</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">/</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">(</span><span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">s</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">^</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">3</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">-</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">5</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">*</span><span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">s</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">+</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">4</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">)</span>
<span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">rep</span><span class="scilaboperator" style="font-style:normal; color:rgb(92,92,92)">=</span><span class="scilabcommand" style="font-style:normal; color:rgb(50,185,185)">freq</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">(</span><span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">(</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">"</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">num</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">"</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">)</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabid" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">(</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">"</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">den</span><span class="scilabstring" style="font-style:normal; color:rgb(188,143,143)">"</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">)</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">[</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">0</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">0.9</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">1.1</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">2</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">3</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">10</span><span class="scilabdefault" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="scilabnumber" style="font-style:normal; color:rgb(188,143,143)">20</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">]</span><span class="scilabopenclose" style="font-style:normal; color:rgb(74,85,219)">)

</span></pre>
<a class="moz-txt-link-freetext" href="https://help.scilab.org/docs/6.0.1/en_US/repfreq.html">https://help.scilab.org/docs/6.0.1/en_US/repfreq.html</a> (syntax)<br>
<pre style="margin-bottom:0px; margin-top:0px; overflow-x:auto; width:819.115px; word-wrap:break-word; color:rgb(0,0,0); font-style:normal; font-weight:400; letter-spacing:normal; orphans:2; text-align:start; text-indent:0px; text-transform:none; widows:2; word-spacing:0px"><span class="default" style="font-style:normal; color:rgb(0,0,0)">[ [</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">frq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,] </span><span class="default" style="font-style:normal; color:rgb(0,0,0)">repf</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">]=</span><span class="functionid" style="font-weight:bold; color:rgb(0,0,0)">repfreq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">(</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">fmin</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">fmax</span><span class="default" style="font-style:normal; color:rgb(0,0,0)"> [,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">step</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">])</span>
<span class="default" style="font-style:normal; color:rgb(0,0,0)">[ [</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">frq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,] </span><span class="default" style="font-style:normal; color:rgb(0,0,0)">repf</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">]=</span><span class="functionid" style="font-weight:bold; color:rgb(0,0,0)">repfreq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">(</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="default" style="font-style:normal; color:rgb(0,0,0)"> [,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">frq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">])</span>
<span class="default" style="font-style:normal; color:rgb(0,0,0)">[ </span><span class="default" style="font-style:normal; color:rgb(0,0,0)">frq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">repf</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">splitf</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">]=</span><span class="functionid" style="font-weight:bold; color:rgb(0,0,0)">repfreq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">(</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">fmin</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">fmax</span><span class="default" style="font-style:normal; color:rgb(0,0,0)"> [,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">step</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">])</span>
<span class="default" style="font-style:normal; color:rgb(0,0,0)">[ </span><span class="default" style="font-style:normal; color:rgb(0,0,0)">frq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">repf</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">splitf</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">]=</span><span class="functionid" style="font-weight:bold; color:rgb(0,0,0)">repfreq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">(</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">sys</span><span class="default" style="font-style:normal; color:rgb(0,0,0)"> [,</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">frq</span><span class="default" style="font-style:normal; color:rgb(0,0,0)">])</span></pre>
<br>
... So, the thing with the matlab freqz (as the example repeated below shows) is just a basic FFT with sampling, etc:<br>
<br>
<span style="color:rgb(0,0,0)">h</span> <span style="color:rgb(92,92,92)">=</span>
<span style="color:rgb(50,185,185)">rand</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">64</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(100,174,100); font-style:italic">// impulse response</span> (Matlab source code)<br>
<span style="color:rgb(0,0,0)">fs</span> <span style="color:rgb(92,92,92)">=</span>
<span style="color:rgb(188,143,143)">1000</span><span style="color:rgb(0,0,0)">;</span><br>
<span style="color:rgb(0,0,0)">Nfft</span> <span style="color:rgb(92,92,92)">=</span>
<span style="color:rgb(188,143,143)">128</span><span style="color:rgb(0,0,0)">;</span><br>
<span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">H</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">F</span><span style="color:rgb(74,85,219)">]</span>
<span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">freqz</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">h</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">Nfft</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">fs</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span><br>
<span style="color:rgb(0,0,0)">semilogx</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">F</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">mag2db</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(50,185,185)">abs</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">H</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;
</span><span style="color:rgb(0,0,0)">grid</span> <span style="color:rgb(0,0,0)">
on</span><span style="color:rgb(0,0,0)">;</span><br>
<span style="color:rgb(0,0,0)">xlabel</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">Frequency (Hz)</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;
</span><span style="color:rgb(0,0,0)">ylabel</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">Magnitude (dB)</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span><br>
<br>
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.<br>
<br>
Best regards,<br>
Claus<br>
<br>
On 15.09.2018 00:32, Samuel Gougeon wrote:<br>
</div>
<blockquote type="cite">
<div class="moz-cite-prefix">Le 14/09/2018 à 20:57, Claus Futtrup a écrit :<br>
</div>
<blockquote type="cite">
<p>Dear Scilabers</p>
<p>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?</p>
<span style="color:rgb(0,0,0)">https</span><span style="color:rgb(255,170,0)">:</span><span style="color:rgb(100,174,100); font-style:italic">//www.mathworks.com/matlabcentral/answers/350350-how-to-plot-loudspeaker-frequency-response-from-its-impulse-response</span>
<p>For example, to replicate the code snippet (second answer in above link), how to do this in Scilab?</p>
<span style="color:rgb(0,0,0)">h</span> <span style="color:rgb(92,92,92)">=</span>
<span style="color:rgb(50,185,185)">rand</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">64</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(100,174,100); font-style:italic">// impulse response</span> (Matlab source code)<br>
<span style="color:rgb(0,0,0)">fs</span> <span style="color:rgb(92,92,92)">=</span>
<span style="color:rgb(188,143,143)">1000</span><span style="color:rgb(0,0,0)">;</span><br>
<span style="color:rgb(0,0,0)">Nfft</span> <span style="color:rgb(92,92,92)">=</span>
<span style="color:rgb(188,143,143)">128</span><span style="color:rgb(0,0,0)">;</span><br>
<span style="color:rgb(74,85,219)">[</span><span style="color:rgb(0,0,0)">H</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">F</span><span style="color:rgb(74,85,219)">]</span>
<span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">freqz</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">h</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">Nfft</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">fs</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span><br>
</blockquote>
<br>
Did you have a look around freq() or repfreq()?<br>
<br>
We have somewhat the equivalence <span class="fontstyle0">invfreqz(H,F,m,n,W)  <=> 
</span><span class="fontstyle0">frfit(F*2*%pi, H, n, W) // Scilab<br>
<br>
So you may look for the reciprocal of Scilab's frfit()</span> <br style="font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px">
<style>
<!--
br
        {}
tr
        {}
td
        {border:.5pt solid windowtext}
.NormalTable
        {border-collapse:collapse;
        border:none}
.fontstyle0
        {font-family:ArialMT;
        font-size:11pt;
        font-style:normal;
        font-weight:normal;
        color:rgb(0,0,0)}
.fontstyle1
        {font-size:12pt;
        font-style:normal;
        font-weight:normal;
        color:rgb(0,0,0)}
-->
</style><br>
HTH<br>
Samuel<br>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset> <br>
<pre>_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<p><br>
</p>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #D3D4DE">
<tbody>
<tr>
<td style="width:55px; padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width:46px; height:29px"></a></td>
<td style="width:470px; padding-top:12px; color:#41424e; font-size:13px; font-family:Arial,Helvetica,sans-serif; line-height:18px">
Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color:#4453ea">
www.avast.com</a> </td>
</tr>
</tbody>
</table>
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>
</div>
</body>
</html>