nass-simscape/Identification/compare_measurements.m
2018-06-16 22:57:54 +02:00

192 lines
8.5 KiB
Matlab

%% Script Description
% Compare identification from the Simscape model
% with the identification on the real system.
%%
clear;
close all;
clc
%% Get Measurement Object
% load('~/ownCloud/Measurements/2017-11-17 - Marc/data/2017_11_17.mat', 'm_object')
load([char(java.lang.System.getProperty('user.home')), '\ownCloud\Measurements\2018-01-12 - Marc\data\2018_01_12_pc.mat'], 'm_object')
%% Get Measurements
% Define Options for measurements
meas_opts = struct( ...
'coh_min', 50, ...
'freq_min', 20 ...
);
measure_dirs = {{'tx', 'tx'}, {'ty', 'ty'}, {'tz', 'tz'}};
% Get measures
measures = getAllMeasure(m_object, 'marble', 'hexa', measure_dirs, meas_opts);
%%
load('./mat/id_G_h_h.mat', 'G_h_h');
load('./mat/id_G_g_g.mat', 'G_g_g');
load('./mat/id_G_h_g.mat', 'G_h_g');
%%
freqs = logspace(1, 3, 2000);
%% Granite to Granite
figure;
hold on;
plot(measures.Fmx.Dmx.freq_filt, abs(measures.Fmx.Dmx.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_g_g(1, 1), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(Granite)_x \rightarrow D(granite)_x$');
exportFig('comp_model_meas_Fmx_Dmx', struct('path', 'Identification'));
%
figure;
hold on;
plot(measures.Fmy.Dmy.freq_filt, abs(measures.Fmy.Dmy.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_g_g(2, 2), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(Granite)_y \rightarrow D(granite)_y$');
exportFig('comp_model_meas_Fmy_Dmy', struct('path', 'Identification'));
%
figure;
hold on;
plot(measures.Fmz.Dmz.freq_filt, abs(measures.Fmz.Dmz.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_g_g(3, 3), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(Granite)_z \rightarrow D(granite)_z$');
exportFig('comp_model_meas_Fmz_Dmz', struct('path', 'Identification'));
% All together
figure;
hold on;
plot(measures.Fmx.Dmx.freq_filt, abs(measures.Fmx.Dmx.resp_filt), '-', 'Color', [0 0.4470 0.7410], 'DisplayName', '$F_{m_x} \rightarrow D_{m_x}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_g_g(1, 1), freqs, 'Hz'))), '--', 'Color', [0 0.4470 0.7410], 'DisplayName', '$F_{m_x} \rightarrow D_{m_x}$ - model');
plot(measures.Fmy.Dmy.freq_filt, abs(measures.Fmy.Dmy.resp_filt), '-', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$F_{m_y} \rightarrow D_{m_y}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_g_g(2, 2), freqs, 'Hz'))), '--', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$F_{m_y} \rightarrow D_{m_y}$ - model');
plot(measures.Fmz.Dmz.freq_filt, abs(measures.Fmz.Dmz.resp_filt), '-', 'Color', [0.9290 0.6940 0.1250], 'DisplayName', '$F_{m_z} \rightarrow D_{m_z}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_g_g(3, 3), freqs, 'Hz'))), '--', 'Color', [0.9290 0.6940 0.1250], 'DisplayName', '$F_{m_z} \rightarrow D_{m_z}$ - model');
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
legend('location', 'northeast');
exportFig('comp_model_meas_Fm_Dm', 'wide-tall', struct('path', 'Identification'));
%% Hexapod to Hexapod
figure;
hold on;
plot(measures.Fhx.Dhx.freq_filt, abs(measures.Fhx.Dhx.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_h_h(1, 1), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(\mu Hexapod)_x \rightarrow D(\mu Hexapod)_x$');
exportFig('comp_model_meas_Fhx_Dhx', struct('path', 'Identification'));
%
figure;
hold on;
plot(measures.Fhy.Dhy.freq_filt, abs(measures.Fhy.Dhy.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_h_h(2, 2), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(\mu Hexapod)_y \rightarrow D(\mu Hexapod)_y$');
exportFig('comp_model_meas_Fhy_Dhy', struct('path', 'Identification'));
%
figure;
hold on;
plot(measures.Fhz.Dhz.freq_filt, abs(measures.Fhz.Dhz.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_h_h(3, 3), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(\mu Hexapod)_z \rightarrow D(\mu Hexapod)_z$');
exportFig('comp_model_meas_Fhz_Dhz', struct('path', 'Identification'));
% All together
figure;
hold on;
plot(measures.Fhx.Dhx.freq_filt, abs(measures.Fhx.Dhx.resp_filt), '-', 'Color', [0 0.4470 0.7410], 'DisplayName', '$F_{h_x} \rightarrow D_{h_x}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_h_h(1, 1), freqs, 'Hz'))), '--', 'Color', [0 0.4470 0.7410], 'DisplayName', '$F_{h_x} \rightarrow D_{h_x}$ - model');
plot(measures.Fhy.Dhy.freq_filt, abs(measures.Fhy.Dhy.resp_filt), '-', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$F_{h_y} \rightarrow D_{h_y}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_h_h(2, 2), freqs, 'Hz'))), '--', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$F_{h_y} \rightarrow D_{h_y}$ - model');
plot(measures.Fhz.Dhz.freq_filt, abs(measures.Fhz.Dhz.resp_filt), '-', 'Color', [0.9290 0.6940 0.1250], 'DisplayName', '$F_{h_z} \rightarrow D_{h_z}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_h_h(3, 3), freqs, 'Hz'))), '--', 'Color', [0.9290 0.6940 0.1250], 'DisplayName', '$F_{h_z} \rightarrow D_{h_z}$ - model');
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
legend('location', 'southwest');
exportFig('comp_model_meas_Fh_Dh', 'wide-tall', struct('path', 'Identification'));
%% Hexapod to Granite
figure;
hold on;
plot(measures.Fhx.Dmx.freq_filt, abs(measures.Fhx.Dmx.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_h_g(1, 1), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(\mu Hexapod)_x \rightarrow D(Granite)_x$');
exportFig('comp_model_meas_Fhx_Dmx', struct('path', 'Identification'));
%
figure;
hold on;
plot(measures.Fhy.Dmy.freq_filt, abs(measures.Fhy.Dmy.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_h_g(2, 2), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(\mu Hexapod)_y \rightarrow D(Granite)_y$');
exportFig('comp_model_meas_Fhy_Dmy', struct('path', 'Identification'));
%
figure;
hold on;
plot(measures.Fhz.Dmz.freq_filt, abs(measures.Fhz.Dmz.resp_filt))
plot(freqs, abs(squeeze(freqresp(G_h_g(3, 3), freqs, 'Hz'))));
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [$Hz$]'); ylabel('Amplitude [$m/N$]');
legend({'meas.', 'id.'}, 'location', 'northwest');
title('Transfer function: $F(\mu Hexapod)_z \rightarrow D(Granite)_z$');
exportFig('comp_model_meas_Fhz_Dmz', struct('path', 'Identification'));
% All together
figure;
hold on;
plot(measures.Fhx.Dmx.freq_filt, abs(measures.Fhx.Dmx.resp_filt), '-', 'Color', [0 0.4470 0.7410], 'DisplayName', '$F_{h_x} \rightarrow D_{m_x}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_h_g(1, 1), freqs, 'Hz'))), '--', 'Color', [0 0.4470 0.7410], 'DisplayName', '$F_{h_x} \rightarrow D_{m_x}$ - model');
plot(measures.Fhy.Dmy.freq_filt, abs(measures.Fhy.Dmy.resp_filt), '-', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$F_{h_y} \rightarrow D_{m_y}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_h_g(2, 2), freqs, 'Hz'))), '--', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$F_{h_y} \rightarrow D_{m_y}$ - model');
plot(measures.Fhz.Dmz.freq_filt, abs(measures.Fhz.Dmz.resp_filt), '-', 'Color', [0.9290 0.6940 0.1250], 'DisplayName', '$F_{h_z} \rightarrow D_{m_z}$ - meas.')
plot(freqs, abs(squeeze(freqresp(G_h_g(3, 3), freqs, 'Hz'))), '--', 'Color', [0.9290 0.6940 0.1250], 'DisplayName', '$F_{h_z} \rightarrow D_{m_z}$ - model');
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
xlabel('Frequency [Hz]'); ylabel('Amplitude [m/N]');
legend('location', 'southwest');
exportFig('comp_model_meas_Fh_Dm', 'wide-tall', struct('path', 'Identification'));