3.6 KiB
3.6 KiB
Test Bench APA
- Parameters
- Filter White Noise
- Load Data
- Time Domain Data
- Compute TF estimate and Coherence
- Coherence
- Transfer Function
Parameters
Ts = 1e-4;
Filter White Noise
Glpf = 1/(1 + s/2/pi/500);
Gz = c2d(Glpf, Ts, 'tustin');
Load Data
data = SimulinkRealTime.utils.getFileScopeData('data/apa95ml_5kg.dat').data;
Time Domain Data
figure;
subplot(1,2,1);
plot(data(:, 3), data(:, 1))
ylabel('Input Voltage [V]'); xlabel('Time [s]');
subplot(1,2,2);
plot(data(:, 3), data(:, 2))
ylabel('Output Displacement [m]'); xlabel('Time [s]');
Compute TF estimate and Coherence
win = hann(ceil(1/Ts));
[tf_est, f] = tfestimate(data(:, 1), -data(:, 2), win, [], [], 1/Ts);
[co_est, ~] = mscohere( data(:, 1), -data(:, 2), win, [], [], 1/Ts);
Coherence
figure;
hold on;
plot(f, co_est, 'k-')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Coherence'); xlabel('Frequency [Hz]');
hold off;
Transfer Function
figure;
ax1 = subplot(2, 1, 1);
hold on;
plot(f, abs(tf_est), 'k-')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
ax2 = subplot(2, 1, 2);
hold on;
plot(f, 180/pi*angle(tf_est), 'k-')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
ylabel('Phase'); xlabel('Frequency [Hz]');
legend();
hold off;
linkaxes([ax1,ax2], 'x');
xlim([10, 5000]);