% Analysis % :PROPERTIES: % :header-args: :tangle matlab/frf_analyze.m % :END: %% Load all the measurements % meas_data = {}; % for i = 1:7 % meas_data(i) = {load(sprintf('mat/frf_data_%i.mat', i), 't', 'Va', 'Vs', 'da', 'de')}; % end %% load(sprintf('mat/frf_data_%i_sweep.mat', 1), 't', 'Va', 'Vs', 'da', 'de') %% figure; plot(t, de); %% figure; plot(t, Va); %% Ts = (t(end) - t(1))/(length(t)-1); Fs = 1/Ts; win = hanning(ceil(5*Fs)); % Hannning Windows %% [G_dvf, f] = tfestimate(Va, de, win, [], [], 1/Ts); [G_d, ~] = tfestimate(Va, da, win, [], [], 1/Ts); [G_iff, ~] = tfestimate(Va, Vs, win, [], [], 1/Ts); [coh_dvf, ~] = mscohere(Va, de, win, [], [], 1/Ts); [coh_d, ~] = mscohere(Va, da, win, [], [], 1/Ts); [coh_iff, ~] = mscohere(Va, Vs, win, [], [], 1/Ts); %% figure; hold on; plot(f, coh_dvf); plot(f, coh_d); plot(f, coh_iff); hold off; set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin'); xlim([1, 5e3]); ylim([0, 1]); %% figure; tiledlayout(2, 1, 'TileSpacing', 'None', 'Padding', 'None'); ax1 = nexttile; hold on; plot(f, abs(G_dvf)); plot(f, abs(G_d)); 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; plot(f, 180/pi*angle(G_dvf)); plot(f, 180/pi*angle(G_d)); 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([5, 5e3]); %% figure; tiledlayout(2, 1, 'TileSpacing', 'None', 'Padding', 'None'); ax1 = nexttile; plot(f, abs(G_iff)); set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); ylabel('Amplitude $V_{out}/V_{in}$ [V/V]'); set(gca, 'XTickLabel',[]); hold off; ax2 = nexttile; plot(f, 180/pi*angle(G_iff)); 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([5, 5e3]);