Transient Response Assignment 2010
Transient Response Assignment 2010
1 0 .2
G (s) = =
2 s + 5 0 .4 s + 1
The time domain equation for the step response is given by:
c(t ) = K (1 −e −t T )
Where t would be a user specified time range or a range generate within the
function.
Kwn2
The 2nd order system is given by: G ( s ) =
s 2 + 2ξwn s + wn2
10 5
G (s) = = 2
2 s + 5s + 16 s + 2.5s + 8
2
wn2 = 8 ; 2ξwn = 2.5 ; and Kw n2 = 5 Therefore all three terms can be calculated. This
is key to generate the correct second order plot.
The time-domain equations for the three possible response of a second order
system are summarize as follows:
The size of the damping ratio constant of the system determines the type of
response:
1
ii) If the damping ratio is equal to one then the response is critical:
c( t ) = K − K (1 + wn t ) e −ξwnt
iii) If the damping ratio is greater than one then the response is overdamped:
Your major challenge will be entering the equations correctly so that they work.
Develop a function that will use the basic plot command to generate the
step-response plot of a first or second order system based on the set of
time domain equations provided. The function/script should use as input
arguments the user specified model parameters. The time range can also
be specified as an input argument or be generated internally.
2
y = sqrt(x) – returns the square root of a scalar or the elements of a vector
or matrix.
Please enter a row vector of 3 values, use [ and ] to enclose your entry: [1,2,3,4]
rowvect = Upon pressing enter the following prompt appears with the cursor one
1 2 3 4 blank space away from the colon so the user entry doesn’t appear to
run into the last word
>>
Please enter a row vector of 3 values, use [ and ] to enclose your
Note that the user didn’t follow instructions and 4 values instead of 3 were enter,
the following is an an example using the input command within a script (function)
and writing the necessary code to ensure the user entry is correct:
function [ydata, coeff] = testinput(xdata)
%This functions plots a quadratic function that the user specifies
userip= input('Please enter a row vector of 3 coefficient, use [ and ] to enclose your entry: ');
% the following code checks if the user enter the data correctly:
n = length(userip); %could have used the 'size' command also
if n > 3
coeff = userip(1:3); %only use the first 3 values of the user vector
elseif n < 3 % prompt user to re-enter input
maxattempt = 5; %this is number of times the user is allow to re-enter value
retry = 1;
while n ~= 3 && retry <= maxattempt % loops if length not three or retrys not exceeded
userip = input('Row vector should be of length 3, please re-enter vector: ');
else % this branch executes only if n == 3 since other options have been tested
coeff = userip;
end
3
rows = dim(1); cols = dim(2);
ydata = a*xdata.^2 + b*xdata + c*ones(rows,cols); % first return argument
plot(ydata);
- Example use of the length and size command for checking vector
and matrix dimension
%In this first example the user enters 4 values but only 3 is return and is
used to build the quadratic function
Please enter a row vector of 3 coefficient, use [ and ] to enclose your entry: [1,2,3,4]
yrange =
Columns 1 through 10
Columns 11 through 20
Column 21
123.0000
4
quadcoef =
1 2 3
>>
140
120
100
80
60
40
20
0
0 5 10 15 20 25
In this second example the user enters 2 values instead of 3 values and so
is re-prompted to re-enter vector:
Please enter a row vector of 3 coefficient, use [ and ] to enclose your entry: [2,4]
yrange =
1.0000
250
3.5000
200
7.0000
11.5000 150
.
100
219.5000 50
5
0 5 10 15 20 25
241.0000
quadcoef =
2 4 1
Note that the return argument vector for the y-values is now a column vector of
the same dimension as the x data values enter.
An alternative to enter a vector would have been to ask the user to separately enter
the coefficients for a, b, and c:
Or finally this information could have been designed to be provided as input arguments to
the function: