test-bench-nano-hexapod/matlab/identif_analyze_all.m

97 lines
2.1 KiB
Mathematica
Raw Normal View History

2021-06-08 17:31:16 +02:00
%% Clear Workspace and Close figures
clear; close all; clc;
%% Intialize Laplace variable
s = zpk('s');
addpath('./src/');
% Test with one APA
%% Load measurement data for APA number 1
2021-08-11 18:03:35 +02:00
meas_data = {};
2021-06-08 17:31:16 +02:00
for i = 1:6
2021-08-11 18:03:35 +02:00
meas_data(i) = {load(sprintf('mat/frf_data_exc_strut_%i_spindle_0m.mat', i), 't', 'Va', 'Vs', 'de')};
2021-06-08 17:31:16 +02:00
end
%%
2021-08-11 18:03:35 +02:00
Ts = (meas_data{1}.t(end) - (meas_data{1}.t(1)))/(length(meas_data{1}.t)-1);
2021-06-08 17:31:16 +02:00
Fs = 1/Ts;
win = hanning(ceil(1*Fs)); % Hannning Windows
%% DVF
2021-08-11 18:03:35 +02:00
[~, f] = tfestimate(meas_data{1}.Va, meas_data{1}.de, win, [], [], 1/Ts);
2021-06-08 17:31:16 +02:00
2021-08-11 18:03:35 +02:00
G_dvf = zeros(length(f), 6, 6);
2021-06-08 17:31:16 +02:00
for i = 1:6
2021-08-11 18:03:35 +02:00
G_dvf(:, :, i) = tfestimate(meas_data{i}.Va, meas_data{i}.de, win, [], [], 1/Ts);
2021-06-08 17:31:16 +02:00
end
%% IFF
2021-08-11 18:03:35 +02:00
[~, f] = tfestimate(meas_data{1}.Va, meas_data{1}.de, win, [], [], 1/Ts);
2021-06-08 17:31:16 +02:00
2021-08-11 18:03:35 +02:00
G_iff = zeros(length(f), 6, 6);
2021-06-08 17:31:16 +02:00
for i = 1:6
2021-08-11 18:03:35 +02:00
G_iff(:, :, i) = tfestimate(meas_data{i}.Va, meas_data{i}.Vs, win, [], [], 1/Ts);
2021-06-08 17:31:16 +02:00
end
%%
figure;
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
ax1 = nexttile([2,1]);
hold on;
for i =1:6
2021-06-08 17:37:28 +02:00
set(gca,'ColorOrderIndex',i)
2021-08-11 18:03:35 +02:00
plot(f, abs(G_dvf(:,i, i)));
2021-06-08 17:31:16 +02:00
end
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]);
hold off;
ax2 = nexttile;
hold on;
for i =1:6
2021-06-08 17:37:28 +02:00
set(gca,'ColorOrderIndex',i)
2021-08-11 18:03:35 +02:00
plot(f, 180/pi*angle(G_dvf(:,i, i)));
2021-06-08 17:31:16 +02:00
end
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin');
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
hold off;
yticks(-360:90:360);
linkaxes([ax1,ax2],'x');
2021-08-11 18:03:35 +02:00
xlim([10, 1e3]);
2021-06-08 17:31:16 +02:00
%%
figure;
tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None');
ax1 = nexttile([2,1]);
hold on;
for i =1:6
2021-06-08 17:37:28 +02:00
set(gca,'ColorOrderIndex',i)
2021-08-11 18:03:35 +02:00
plot(f, abs(G_iff(:,i, i)));
2021-06-08 17:31:16 +02:00
end
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]);
hold off;
ax2 = nexttile;
hold on;
for i =1:6
2021-06-08 17:37:28 +02:00
set(gca,'ColorOrderIndex',i)
2021-08-11 18:03:35 +02:00
plot(f, 180/pi*angle(G_iff(:,i, i)));
2021-06-08 17:31:16 +02:00
end
hold off;
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin');
xlabel('Frequency [Hz]'); ylabel('Phase [deg]');
hold off;
yticks(-360:90:360);
linkaxes([ax1,ax2],'x');
2021-06-08 17:37:28 +02:00
xlim([20, 2e3]);