0% found this document useful (0 votes)
5 views8 pages

Questions 1-2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Questions 1-2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Simulation 2

RECALL:
Constructing a transfer function in Scilab:
• Use poly to create a symbolic variable for s.
• Use syslin to obtain a continuous-time system.

Solution:

s = poly(0, 's'); //Create a symbolic variable for s


P = 1/(10*s^2+0.1*s) // Our function
P = syslin('c',P) // Continuous-time system
y = csim(u, t, P); // for simulating the time response
of a system based on a defined input signal, where u is the unit
step signal, t is the vector time and P is the Continuous-time
system signal.
Question 1:Compare open loop and closed loop
systems using SCILAB.
Solution: OPEN LOOP

delta = 0.1; // Define damping ratio δ


// Define the transfer function G(s) = 1 / (s^2 + 2*δ*s + 36)
s = poly(0, 's’);
P = 1/(s^2+2*delta*s+36) // Our function
P = syslin('c',P) // Continuous-time system
// Open-loop step response
t = 0:0.1:50; // Time vector
u = ones(t); // step input of size t
y = csim(u, t, P); // for simulating the time response
of a system based on a defined input signal
Question 1:Compare open loop and closed loop
systems using SCILAB.
Solution: OPEN LOOP

subplot(2, 1, 1);
plot(t, y);
title("Step Response of the Plant – Open Loop");
xlabel("Time (s)");
ylabel("Amplitude");
Question 1:Compare open loop and closed loop
systems using SCILAB.
Solution: CLOSED LOOP

// Closed-loop transfer function T(s) = G(s) / (1 + G(s))


H = 1; // Unity feedback
T = P / (1 + P *H); // Closed-loop transfer function

y2 = csim(u, t, T);
subplot(2, 1, 2);
plot(t, y2);
title("Step Response of the Plant – Closed Loop");
xlabel("Time (s)");
ylabel("Amplitude");
Question 2:Study transient response for a given system
using SCILAB.
Solution:

s = poly(0, 's');
// Define the damping ratio
zeta1 = 0.9;
zeta2 = 6;
zeta3 = 20;
// Define the transfer functions for each case
H1 = 1 / (s^2 + 2*zeta1*s + 36);
H2 = 1 / (s^2 + 2*zeta2*s + 36);
H3 = 1 / (s^2 + 2*zeta3*s + 36);
Question 2:Study transient response for a given system
using SCILAB.
// Create the continuous-time systems
sys1 = syslin('c', H1);
sys2 = syslin('c', H2);
sys3 = syslin('c', H3);
// Define the time vector (0 to 20 seconds)
t = 0:0.1:20;
// Define the step input (vector of ones)
u = ones(t);
// Simulate the responses of each system
y1 = csim(u, t, sys1);
y2 = csim(u, t, sys2);
y3 = csim(u, t, sys3);
Question 2:Study transient response for a given system
using SCILAB.
// Plot the responses
plot(t, y1, 'r', t, y2, 'g', t, y3, 'b');
legend('z1', 'z2', 'z3');
xlabel('Time (s)');
ylabel('Output');
title('Step Response for a Second-Order System');

You might also like