0% found this document useful (0 votes)
33 views

Matlab 4

This document describes simulating a first-order difference equation in Simulink. The difference equation is y[n]=-0.5y[n-1]+x[n] with an initial condition of y[-1]=1 and input x[n] being a step function with amplitude 1. The solution y[n] is viewed in the scope block. Settings like sample time must be configured before running the simulation. Blocks like integer delay and gain are used to model the difference equation.

Uploaded by

joker prince
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Matlab 4

This document describes simulating a first-order difference equation in Simulink. The difference equation is y[n]=-0.5y[n-1]+x[n] with an initial condition of y[-1]=1 and input x[n] being a step function with amplitude 1. The solution y[n] is viewed in the scope block. Settings like sample time must be configured before running the simulation. Blocks like integer delay and gain are used to model the difference equation.

Uploaded by

joker prince
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Exercise : In this example we will try to illustrate how a difference equation will look

like: y[n]= -0.5*y[n-1]+x[n] and a initial condition y[-1]=1

Further we know that our input signal is a step applied at n=0 with amplitude 1.

Scope
-1
Z
Step Integer Delay

0.5

Gain

Figure
In the scope we can find the solution y[n]. The initial condition is inserted in the Delay
block. I can also select the sampling time in seconds. This can be inserted in both the
Delay and Step block. The output is shown below in figure 12. The Integer Delay can be
found in library: Simulink-> Discrete
Before you run the simulation. Change in Simulation-> Configuration Parameters.
Choose the following: Solver Options-> Fixed-step and Solver-> Discrete
Notice that the difference equation can be formulated from the sum block.
Choose the sample time in each block to 1 sec ( Integer Delay, Step and Gain ).

6
EXERCISE 1. Typical step response of First order Systems

E2 – Step 1. Start the Simulink environment by typing “simulink” to the matlab prompter.
E2 – Step 2. Open a new simulink mode from the File  New  Model
E2 – Step 3. Drag and drop the blocks below from the Simulink windows into the model
window (select “transfer function” from the “Continuous” group; “Step” from
“Sources”; “Scope” from “Sinks”, “Mux” from “Signal Routing”, etc.)
E2 – Step 4. Double click the blocks the set up different first order transfer functions.
Observe the effect of gain and time constant on the dynamic response of the
system.

(A)

(B)

(C)

E2 – Step 5. Identify which response belongs to which transfer function:

Transfer function 1 has response _____;

Transfer function 2 has response _____;

Transfer function 3 has response _____;


EXERCISE 1. Typical open-loop dynamic responses of second order systems

E1 – Step 1. Start the Simulink environment by typing “simulink” to the matlab prompter.
E1 – Step 2. Open a new simulink mode from the File Æ New Æ Model
E1 – Step 3. Drag and drop the blocks below from the Simulink windows into the model
window
E1 – Step 4. Double click the blocks the set up different second order transfer functions.
Define one overdamped, one critically damped and one under damped system.
E1 – Step 5. Connect the blocks together as shown below:

E1 – Step 6. Set the simulation time to 30 sec from the menu “Simulation” Æ
“Configuration parameters”

E1 – Step 7. Simulate the process by pressing the “Run” button and then show the results
by double clicking on the “Scope” block:
Run simulation

Autoscale figure

E1 – Step 8. INDIVIDUAL EXERCISE – Change the form of the transfer function to simulate
(i) an unstable behaviour and (ii) a system at the limit of instability (with sustained
oscillations).

You might also like