hi = load('mat/pi_505_high.mat', 't', 'V_in', 'V_out'); lo = load('mat/pi_505_low.mat', 't', 'V_in', 'V_out'); %% run setup; win = hann(ceil(0.1/Ts)); [tf_hi, f_hi] = tfestimate(hi.V_in, hi.V_out, win, [], [], 1/Ts); [co_hi, ~] = mscohere(hi.V_in, hi.V_out, win, [], [], 1/Ts); [tf_lo, f_lo] = tfestimate(lo.V_in, lo.V_out, win, [], [], 1/Ts); [co_lo, ~] = mscohere(lo.V_in, lo.V_out, win, [], [], 1/Ts); %% figure; ax1 = subplot(2, 1, 1); hold on; plot(f_hi, abs(tf_hi), 'DisplayName', 'high') plot(f_lo, abs(tf_lo), 'DisplayName', 'low') set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log'); ylabel('Amplitude'); xlabel('Frequency [Hz]'); hold off; legend('location', 'southwest'); ylim([0.1, 20]); ax2 = subplot(2, 1, 2); hold on; plot(f_hi, 180/pi*unwrap(angle(tf_hi))) plot(f_lo, 180/pi*unwrap(angle(tf_lo))) set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'lin'); ylabel('Phase'); xlabel('Frequency [Hz]'); hold off; ylim([-360, 0]); linkaxes([ax1,ax2], 'x'); xlim([10, 5000]);