Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Do you actually know the transfer function? Is implemented correctly in Simulink? Then the error suggests that you haven't assigned the correct variable name to your from workspace block, you just kept the default <code>VariableName</code>. For the frequency response you need to define your transfer function outside Simulink with <code>tf</code>, then use <code>bodeplot</code> to plot it. (Look at the end of these answer)</p> <hr> <p>But it appears to me, that you have some <strong>inputdata</strong> and some <strong>outputdata</strong> and you'd like to <strong>estimate the transfer function</strong> and finally get the frequency response of that transfer function. There is no need for Simulink to do that. Once you found your transfer function you could implement it into Simulink using the <code>Transfer function</code> block, feed the simulation with the <code>From Workspace</code> Block and display the results with <code>Scope</code>. But first you need the transfer function.</p> <p>Assuming you have the variables <code>inputdata</code> and <code>outputdata</code> you first need to create a transfer function dataset:</p> <pre><code>% prepare data for tftest, 100 is a random chosen sampling time tfdata = iddata(data(:,1),data(:,2),100); </code></pre> <p>then you can use <code>tfest</code> to estimate the transfer function with a chosen number of poles:</p> <pre><code>N = 5; % Number of poles sys = tfest(tfdata,N); </code></pre> <p>The frequency response you get e.g. with <code>bodeplot</code>:</p> <pre><code>bodeplot(sys) </code></pre> <p>The function <code>FREQZ</code> you intended to use is just for digital filters, not for transfer functions.</p> <p>Finally you can test your model with Simulink:</p> <p><img src="https://i.stack.imgur.com/JKbzj.jpg" alt="enter image description here"></p> <p>where the numerator of the <code>Transfer Fcn</code> Block is <code>sys.num{1}</code> and the denominator <code>sys.den{1}</code> (for my example).</p> <p>If the graph displayed in <code>Scope</code> (be aware that you should disable "Limit Data points to last 5000" in the scope Settings) is similar to your <code>outputdata</code> the estimation was successful.</p> <hr> <p>I made a testrun for your model: (fixed step solver, no continuous states, 0.0001 steptime).</p> <p><img src="https://i.stack.imgur.com/UYfBr.jpg" alt="enter image description here"></p> <p>Then the following code:</p> <pre><code>tfdata = iddata(inputdata,outputdata,0.0001); N = 5; sys = tfest(tfdata,N); bodeplot(sys) </code></pre> <p>returning:</p> <pre><code>sys = From input "u1" to output "y1": -2068 s^4 + 2.89e06 s^3 + 7.017e10 s^2 + 5.205e13 s - 8.931e15 ------------------------------------------------------- s^5 + 1.034e04 s^4 + 4.552e07 s^3 + 1.114e11 s^2 + 8.337e13 s + 8.931e15 </code></pre> <p>and:</p> <p><img src="https://i.stack.imgur.com/9JHkz.jpg" alt="enter image description here"></p> <p>or convert it to discrete:</p> <pre><code>sysd = c2d(sys,0.0001) sysd = From input "u1" to output "y1": -0.0995 z^-1 + 0.4644 z^-2 - 0.7491 z^-3 + 0.5061 z^-4 - 0.1219 z^-5 ------------------------------------------------------- 1 - 4.042 z^-1 + 6.554 z^-2 - 5.332 z^-3 + 2.176 z^-4 - 0.3556 z^-5 </code></pre> <p>I can't help you more, and it's a homework anyway, right? So the rest is up to you. And honestly, calculate it by hand! It will be much more exact!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload