33 lines
386 B
Plaintext
33 lines
386 B
Plaintext
close all
|
|
clear all
|
|
clc
|
|
|
|
Ts = 0.1;
|
|
|
|
%% 1
|
|
num = [2 1];
|
|
den = [1 2 1];
|
|
|
|
G = tf(num,den);
|
|
|
|
Gd = c2d(G,Ts)
|
|
|
|
[yc,tc] = step(G);
|
|
[yd,td] = step(Gd);
|
|
|
|
plot(tc,yc);
|
|
hold on
|
|
plot(td,yd);
|
|
hold on
|
|
legend('continuous','discrete');
|
|
title('Continuous and discrete step response')
|
|
xlabel('time (s)')
|
|
ylabel('amplitude (a.u.)')
|
|
|
|
|
|
%% 2
|
|
|
|
num2 = [0.047 0.046];
|
|
den2 = [1 -1.81 0.9];
|
|
|
|
Hd = tf(num2,den2,Ts) |