%% 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 meas_data = {}; for i = 1:6 meas_data(i) = {load(sprintf('mat/frf_data_exc_strut_%i_spindle_0m.mat', i), 't', 'Va', 'Vs', 'de')}; end %% Ts = (meas_data{1}.t(end) - (meas_data{1}.t(1)))/(length(meas_data{1}.t)-1); Fs = 1/Ts; win = hanning(ceil(1*Fs)); % Hannning Windows %% DVF [~, f] = tfestimate(meas_data{1}.Va, meas_data{1}.de, win, [], [], 1/Ts); G_dvf = zeros(length(f), 6, 6); for i = 1:6 G_dvf(:, :, i) = tfestimate(meas_data{i}.Va, meas_data{i}.de, win, [], [], 1/Ts); end %% IFF [~, f] = tfestimate(meas_data{1}.Va, meas_data{1}.de, win, [], [], 1/Ts); G_iff = zeros(length(f), 6, 6); for i = 1:6 G_iff(:, :, i) = tfestimate(meas_data{i}.Va, meas_data{i}.Vs, win, [], [], 1/Ts); end %% figure; tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None'); ax1 = nexttile([2,1]); hold on; for i =1:6 set(gca,'ColorOrderIndex',i) plot(f, abs(G_dvf(:,i, i))); 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 set(gca,'ColorOrderIndex',i) plot(f, 180/pi*angle(G_dvf(:,i, i))); 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'); xlim([10, 1e3]); %% figure; tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None'); ax1 = nexttile([2,1]); hold on; for i =1:6 set(gca,'ColorOrderIndex',i) plot(f, abs(G_iff(:,i, i))); 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 set(gca,'ColorOrderIndex',i) plot(f, 180/pi*angle(G_iff(:,i, i))); 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'); xlim([20, 2e3]);