clf;
close all;
x = 0.1;
noverlap = 0.0*w;

na = 4;

signal = vout_0inj_3;
signal = signal(round(x*length(signal)):length(signal));
nx = max(size(signal));
w = hanning(floor(nx/na));
noverlap = round(length(w)*0);
[Pxx,f]=pwelch(signal,w,noverlap,[],1/ts);
Pxx_0inj_3 = Pxx;

signal = vout_2inj_3;
signal = signal(round(x*length(signal)):length(signal));
nx = max(size(signal));
w = hanning(floor(nx/na));
[Pxx,f]=pwelch(signal,w,noverlap,[],1/ts);
Pxx_2inj_3 = Pxx;

f_0inj = f./621.8e6;
f_2inj = f./618e6;

psd_db_0inj = pow2db(Pxx_0inj_3);
psd_db_2inj = pow2db(Pxx_2inj_3);

figure
semilogx(f_0inj,psd_db_0inj, 'DisplayName','no injection')
grid on
hold on
semilogx(f_2inj,psd_db_2inj, 'DisplayName','200 uA')

PSD_0inj = [f_0inj(7000:9000), psd_db_0inj(7000:9000)];
PSD_2inj = [f_2inj(7000:9000), psd_db_2inj(7000:9000)];

