test-bench-apa300ml/matlab/setup.m

24 lines
535 B
Matlab

Fs = 10e3; % [Hz]
Ts = 1/Fs; % [s]
%%
freq_LPF = 0.5; % [Hz]
s = tf('s');
G_lpf = (1)/(1 + s/2/pi/freq_LPF);
Gz = c2d(G_lpf, Ts, 'tustin');
%%
t = 0:Ts:12;
V = -1*ones(size(t));
t0 = 2; t1 = t0 + 1;
V(t < t0-1) = 0;
V(t > t0 & t < t0 + pi) = 3.25 + 4.25*cos(t(t > t0 & t < t0 + pi) - t0 + pi);
V(t > t0 + pi & t < t1 + pi) = 7.5;
V(t > t1 + pi & t < t1 + 2*pi) = 3.25 + 4.25*cos(t(t > t1 + pi & t < t1 + 2*pi) - t1 + pi);
V(t > t1 + 2*pi + 2) = 0;
w0 = 2*pi*10; xi = 1;
V = lsim(1/(1 + 2*xi*s/w0 + s^2/w0^2), V, t);
Vin = [t', V];