Main

ChE 436: Simulink and MATLAB Programming Help

Main.ProjectProgramming History

Hide minor edits - Show changes to output

May 14, 2015, at 03:32 PM by 45.56.3.184 -
Changed line 19 from:
** [[https://www.enthought.com/services/training/python-training-on-demand|Python at Enthough (Free for Academics)
to:
** [[https://www.enthought.com/services/training/python-training-on-demand|Python at Enthought (Free for Academics)]]
May 14, 2015, at 03:32 PM by 45.56.3.184 -
Changed lines 11-14 from:
* [[http://apmonitor.com/che263/|BYU ChE263: Computational Tools]]
* [[http://www.mathworks.com/academia/student_center/tutorials/launchpad.html|MATLAB Tutorials and Learning Resources]]
* [[http://www.codecademy.com/en/tracks/python|Python at CodeAcademy]]
* [[http://www.see.ed.ac.uk/teaching/courses/matlab/|Univ of Edinburgh: MATLAB Intro]]
to:
* MATLAB
**
[[http://apmonitor.com/che263/|BYU ChE263: Computational Tools]]
** [[http://www.mathworks.com/academia/student_center/tutorials/launchpad.html|MATLAB Tutorials and Learning Resources]]
** [[http://www.see.ed.ac.uk/teaching/courses/matlab/|Univ of Edinburgh: MATLAB Intro]]

* Python
**
[[http://apmonitor.com/che263/|BYU ChE263: Computational Tools]]
** [[http://www.codecademy.com/en/tracks/python|Python at CodeAcademy]]
** [[https://www.enthought.com/services/training/python-training-on-demand|Python at Enthough (Free for Academics)
May 12, 2015, at 04:40 PM by 10.14.103.164 -
Added lines 8-14:

There are several online courses and materials that can help students gain basic programming experience in MATLAB or Python. Below are some online resources:

* [[http://apmonitor.com/che263/|BYU ChE263: Computational Tools]]
* [[http://www.mathworks.com/academia/student_center/tutorials/launchpad.html|MATLAB Tutorials and Learning Resources]]
* [[http://www.codecademy.com/en/tracks/python|Python at CodeAcademy]]
* [[http://www.see.ed.ac.uk/teaching/courses/matlab/|Univ of Edinburgh: MATLAB Intro]]
November 27, 2014, at 12:21 AM by 107.188.175.164 -
Added lines 11-12:
----
Changed lines 21-22 from:
!!! Embedding Custom Functions (MATLAB scripts)
to:
----

!!! Simulink Source Signals
Changed line 26 from:
<iframe width="560" height="315" src="//www.youtube.com/embed/XfG9fO4bcNk?rel=0" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="//www.youtube.com/embed/ypz_wzVwdII?rel=0" frameborder="0" allowfullscreen></iframe>
Added lines 29-37:
----
!!! Embedding Custom Functions (MATLAB scripts)

(:html:)
<iframe width="560" height="315" src="//www.youtube.com/embed/XfG9fO4bcNk?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

----

Changed lines 48-49 from:
!!! Example MIMO System
to:
----

!!! Example Multiple-Input, Multiple-Output (MIMO) System
Added lines 58-59:
----
Added lines 61-64:

(:html:)
<iframe width="560" height="315" src="//www.youtube.com/embed/T220082pTLw?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
November 26, 2014, at 05:29 PM by 107.188.175.164 -
Added lines 24-33:

!!! Linear and Nonlinear Simulation

->[[Attach:CSTR_Linearized.zip | Attach:CSTR_Linearized.png]]

* %list list-page% [[Attach:CSTR_Linearized.zip | CSTR Simulink Linear vs. Nonlinear Comparison]]
** Model in State Space Form
** Model in Transfer Function Form
** Model in Nonlinear Form (S-Function)
** See [[Main/CaseStudyCSTR | CSTR Case Study for Additional Examples]]
November 26, 2014, at 05:09 PM by 107.188.175.164 -
Added lines 1-66:
(:title ChE 436: Simulink and MATLAB Programming Help:)
(:keywords MATLAB, Simulink, tutorial, process control:)
(:description Simulation help with the Process Control and Dynamics Lab in Chemical Engineering at Brigham Young University:)

----

!! Simulation Lab Programming Help

Below are a few examples of Simulink and MATLAB programs that can help with projects. Common questions for the simulation labs include how to import data, export results, and configuring more complex systems.

!!! Import Data File into Simulink

Data such as any custom time series can be imported into Simulink. In this example, an Interpreted MATLAB Function block is used to read a data file (data.txt) and interpolate with a linear approximation between the two nearest points.

* %list list-page% [[Attach:interpreted_Simulink_MATLAB.zip | Download Interpreted Function Example (Simulink/MATLAB)]]

->[[Attach:interpreted_Simulink_MATLAB.zip | Attach:interpreted_Simulink_MATLAB.png]]

!!! Embedding Custom Functions (MATLAB scripts)

(:html:)
<iframe width="560" height="315" src="//www.youtube.com/embed/XfG9fO4bcNk?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

!!! Example MIMO System

The following Simulink model is an example of a Multiple-Input Multiple-Output system. The first block is an example of two decoupled PID controllers (non-interacting) while the second block is an example of interacting PID controllers with feedforward gains.

[[Attach:interacting_controllers.zip | Download Interacting Control Example (Simulink)]]

Attach:interacting_controllers.png

!!! Exporting Data from MATLAB / Simulink

You may want to export data from MATLAB or Simulink to combine plots or for further manipulation in another program like Excel. One way is shown below:

Step 1: Drop the "to Workspace" blocks into Simulink and re-run the simulation. The requested variables will be exported to the MATLAB workspace.

Attach:simulink_to_workspace.png

Step 2: From the MATLAB command prompt, view the "input" and "output" data that was generated from the Simulink simulation. Type "input" or "output" to inspect the information that is contained in the variable structure.

Attach:matlab_input_data.png

Step 3: Save the data to a text file. One way is to construct all of the data that will be saved into a data matrix and then export as an ASCII text file (tab delimited). Make sure your current directory allows you to save a file (is not write-restricted) or it will return an error.

Attach:matlab_save_data.png

----

(:html:)
 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)