Question
Write a MATLAB user-defined function that calculates and graphs the step response of a linear system over the time period [0, 10] seconds for any supplied damping ratio z and natural undamped frequency omega. The step response is given by the following function y(t) = 1 - e^-2 omega t (cos (omega(Squareroot 1 - z^2)t) + z/Squareroot 1 - z^1 sin (omega(Squareroot 1 - z^2)t)) where y is the response, t is the time variable, z is the damping ratio and omega is the natural undamped frequency. In addition to the graph, the function must return the maximum system response over the time period [0, 10] seconds. The damping ratio z has to be greater than zero and less than 1. If the function is called with a damping ratio greater than 1 or less than zero, then a proper error message must be returned by the function. Build a MATLAB function called tridiagmatrix.m that creates a symmetric diagonal n times n
Explanation / Answer
The given MATLAB Function takes w(natural undamped frequency) and z(damping ratio) as it's inputs and produces the desired step response along with it's plot.
function response_step(w,z)
if z>=1 || z<=0
disp('Error! Please Enter the value of damping ratio between 0 and 1.');
end
if z>0 && z<1
t=0:0.001:10;
wd=w*sqrt(1-((z)^(2)));
zz=z/sqrt(1-((z)^(2)));
for i=1:length(t)
y1(i)=cos(wd*t(i));
y2(i)=zz*sin(wd*t(i));
y3(i)=exp(-z*w*t(i))*(y1(i)+y2(i));
y(i)=1-y3(i)
end
plot(t,y)
end