# Using Matlab to draw a step response graph

I've got the next transfer function:

$$\frac{\hat{\alpha}}{\hat{\alpha_{ref}}} =\frac{w_n^2}{s^2+2w_n \xi s+ w_n^2}$$

Now I want to draw a step response input at height of $\alpha_{ref}$, where $\xi$ comes with differing values (i.e different graphs on the same axis for different values of $\xi$, and the value of $w_n$ depends on $\xi$).

How to implement this in Matlab?

A not-at-all elegant way to do it is:

zeta=[...]; %your zeta values
wn = ... % calculate your wn values according to your zeta values
figure;
hold('on');
for idx = 1:length(zeta)
% sys = tf([wn(idx)],[1 2*wn(idx)*zeta(idx) wn(idx)^2]); %system's transfer function
% EDIT : numerator corrected
sys = tf([wn(idx)^2],[1 2*wn(idx)*zeta(idx) wn(idx)^2]); %system's transfer function
step(alpharef*sys);
end

• Thanks it should the numerator $wn(idx)^2$, other than that looks ok to me. Nov 18 '12 at 2:57
• I haven't noticed that. Thanks for pointing it out. Edited my answer accordingly. Nov 18 '12 at 11:13
• You can write hold on instead of hold('on'); Nov 18 '12 at 13:39
• Well yeah, but I usually try to use the function syntax. I think it gives the code more consistency. Syntax documentation can be found here: mathworks.com/help/matlab/ref/syntax.html mathworks.com/help/matlab/matlab_prog/… Nov 19 '12 at 6:26