Simulink & GUI in MATLAB: Experiment # 5
Simulink & GUI in MATLAB: Experiment # 5
Introduction to simulink
SOLVER PAGE
The Solver page appears when you first choose Parameters from the Simulation
menu or when you select the Solver tab. The Solver page allows you to:
Set the start and stop times – You can change the start time and stop time for
the simulation by entering new values in the Start time and Stop time fields.
The default start time is 0.0 seconds and the default stop time is 10.0 seconds.
Choose the solver and specify solver parameters – The default solver provide
accurate and efficient results for most problems. Some solvers may be more
efficient that others at solving a particular problem; you can choose between
variable-step and fixed-step solvers. Variable-step solvers can modify their
step sizes during the simulation. These are ode45, ode23, ode113, ode15s,
ode23s, and discrete. The default is ode45. For variable-step solvers, you can
set the maximum and suggested initial step size parameters. By default, these
parameters are automatically determined, indicated by the value auto. For
fixed-step solvers, you can choose ode5, ode4, ode3, ode2, ode1, and
discrete.
Output Options – The Output options area of the dialog box enables you to
control how much output the simulation generates. You can choose from three
popup options. These are: Refine output, Produce additional output, and
Produce specified output only.
DIAGNOSTICS PAGE
The Diagnostics page allows you to select the level of warning messages displayed
during a simulation.
Model the equation that converts Celsius temperature to Fahrenheit. Obtain a display
of Fahrenheit-Celsius temperature graph over a range of 0 to 100 C .
9
TF TC 32
5
First, consider the blocks needed to build the model. These are:
A ramp block to input the temperature signal, from the source library.
A constant block, to define the constant of 32, also from the source library.
A gain block, to multiply the input signal by 9=5, from the Linear library.
A sum block, to add the two quantities, also from the Linear library.
A scope block to display the output, from the sink library.
To create a SIMULINK block diagram presentation select new... from the File menu.
This provides an untitled blank window for designing and simulating a dynamic
system. Copy the above blocks from the block libraries into the new window by
depressing the mouse button and dragging. Assign the parameter values to the Gain
and Constant blocks by opening (double clicking on) each block and entering the
appropriate value. Then click on the close button to apply the value and close the
dialog box. The next step is to connect these icons together by drawing lines
connecting the icons using the left mouse button (hold the button down and drag the
mouse to draw a line).
You should now have the SIMULINK block diagram as shown below:
The Ramp block inputs Celsius temperature. Open this block, set the Slope to 1, Start
time to 0, and the Initial output to 0. The Gain block multiplies that temperature by
the constant 9/5. The sum block adds the value 32 to the result and outputs the
Fahrenheit temperature. Pull down the Simulation dialog box and select Parameters.
Set the Start time to zero and the Stop Time to 100. Double click on the Scope, click
on the Auto Scale, the result is displayed as shown below
Building GUI interfaces in Matlab
This example shows how to build user GUI in Matlab. We will build a simple
calculator to do that.
Start gui builder by typing
>>guide
Double-click on an object to open the properties dialog. Change the captions on the
buttons and remove "Static Text" string from the text window. Set the font size 30 for
the text windows and change horizontal alingment to "right."
The GUI is finished. Save the work.
The rest of the design process will take care of the functionality provided by each
GUI component.
LAB
1. Implement the below function by Simulink
X 2 3
Be sure that the range of the function appears in scope between (-3,10).
2S 3
2
S 3S 2