test-bench-piezo-amplifiers/analysis_level_cedrat.m
2020-08-12 17:53:51 +02:00

43 lines
1.3 KiB
Matlab

hi = load('mat/cedrat_la75b_high_1_stack.mat', 't', 'V_in', 'V_out');
me = load('mat/cedrat_la75b_med_1_stack.mat', 't', 'V_in', 'V_out');
lo = load('mat/cedrat_la75b_low_1_stack.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_me, f_me] = tfestimate(me.V_in, me.V_out, win, [], [], 1/Ts);
[co_me, ~] = mscohere(me.V_in, me.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_lo, abs(tf_lo), 'DisplayName', 'low')
plot(f_me, abs(tf_me), 'DisplayName', 'med')
plot(f_hi, abs(tf_hi), 'DisplayName', 'high')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude'); xlabel('Frequency [Hz]');
hold off;
legend('location', 'southwest');
ylim([0.1, 50]);
ax2 = subplot(2, 1, 2);
hold on;
plot(f_lo, 180/pi*unwrap(angle(tf_lo)))
plot(f_me, 180/pi*unwrap(angle(tf_me)))
plot(f_hi, 180/pi*unwrap(angle(tf_hi)))
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]);