% ***** MATLAB Code Starts Here %
K = [1 2 4 8 16];
ts0 = linspace(0,2,1001);
ts1 = 3*ts0;
ts2 = 20*ts0;
tr0 = 10*ts0;
tr1 = tr0; tr2 = 2*tr0;
n0 = 1; n1 = n0;
n2 = [1 1];
d0 = conv([1/2 1],[1/50 1]);
d1 = [d0 0]; d2 = [d1 0];
for
i = 1:length(K)for i1 = 1:3
eval([
'[n,d] = cloop(K(i)*n' num2str(i1-1) ',d' num2str(i1-1) ',-1);'])eval([
'ys' num2str(i1-1) '(:,' num2str(i) ') = step(n,d,ts' num2str(i1-1) ');']);eval([
'yr' num2str(i1-1) '(:,' num2str(i) ') = step(n,[d 0],tr' num2str(i1-1) ');'])end
end
for
i = 1:3
eval([
'ts = ts' num2str(i-1) ';']);eval([
'ys = ys' num2str(i-1) ';']);eval([
'tr = tr' num2str(i-1) ';']);eval([
'yr = yr' num2str(i-1) ';']);
figure(i),clf,set(i,
'Position',[62 50 942 660]),... subplot(121),... plot(ts,ys),grid,xlabel('Time (s)'),ylabel('Amplitude'),... name = ['Type ' num2str(i-1) ' Step Response'];title(name),...subplot(122),... plot(tr,yr,[0 max(tr)],[0 max(tr)],'k--'),grid,... xlabel('Time (s)'),ylabel('Amplitude'),... name = ['Type ' num2str(i-1) ' Ramp Response'];title(name),...
end
figure(1),subplot(121),text(1.2,0.52,
'K = 1'),text(1.2,0.7,'K = 2'),text(1.2,0.82,'K = 4'),...text(0.7,0.87,
'K = 8'),text(1.2,0.96,'K = 16'),subplot(122),text(7,3,'K = 1')figure(2),subplot(121),text(0.5,0.1,
'K = 1'),subplot(122),text(2.5,1,'K = 1')figure(3),subplot(121),text(3,1.7,
'K = 1'),subplot(122),text(3,1,'K = 1')% % ***** MATLAB Code Stops Here
Click the
icon to return to the Dr. Beale's home page
Lastest revision on Friday, May 26, 2006 9:29 PM