UP | HOME

# Test Bench APA
Author: Dehaeze Thomas

## Table of Contents

- 1. Parameters
- 2. Filter White Noise
- 3. Load Data
- 4. Time Domain Data
- 5. Compute TF estimate and Coherence
- 6. Coherence
- 7. Transfer Function

## 1 Parameters

    Ts = 1e-4;

## 2 Filter White Noise

    Glpf = 1/(1 + s/2/pi/500);

    Gz = c2d(Glpf, Ts, 'tustin');

## 3 Load Data

    data = SimulinkRealTime.utils.getFileScopeData('data/apa95ml_5kg.dat').data;

## 4 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]');

## 5 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);

## 6 Coherence

    figure;

    hold on;
    plot(f, co_est, 'k-')
    set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin');
    ylabel('Coherence'); xlabel('Frequency [Hz]');
    hold off;

## 7 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]);

Author: Dehaeze Thomas

Created: 2020-07-17 ven. 11:55