% mysos.m

% clear command window and variable memory
clc
clear

% define 2nd order system parameters and model
% wn = 1;      % natural frequency
% z = .1;      % damping ratio
wn = input ('natural frequency (wn): ');
z = input ('damping ratio (zeta): ');
n = wn^2;
d = [1 2*z*wn wn^2];
g = tf(n, d);

% step response
step (g)
 
% % frequency response
% figure    % create new plot window
% w = 0 : wn/10 : 5*wn;
% gjw = freqs(n, d, w);
% gmag = abs (gjw);
% plot (w, gmag);
% % alternative method:
% % gjw = freqresp (g, w);
% % gmag = abs (gjw);
% % [m n] = size(w);
% % i = 1 : n;
% % yw(i) = gmag (1, 1, i);
% % plot (w, yw);
% title('Frequency Response');
% xlabel('frequency');
% ylabel('magnitude');
% 
% % phase plot
% gph = angle(gjw) * 180/pi;
% figure
% plot (w, gph);
% title('Phase Response');
% xlabel('frequency');
% ylabel('phase (deg)');

% pause for the user
display ('Hit Enter to continue');
pause

% remove figures
close all
clc