Violet_AGH
Newbie level 2
Hi!
I've made the measurement of signal (with oscilloscope) and noise of the amplifiers. I have put them on svanpc and put the into Matlab.
My task is to calculate the SNR, THD and the bandwith. And I have no idea what I am doing. I have got some numbers but I think it's all wrong (SNR=18,24dB, I dont think it should looks like this). It also look very short so I have to do somenthing wrong, something like everything. Can anyone tell me where I do mistakes? Thank you in advance.
Here is my code. I cut some data to make look this better (I had 100 samples, let's make only 10)
I've made the measurement of signal (with oscilloscope) and noise of the amplifiers. I have put them on svanpc and put the into Matlab.
My task is to calculate the SNR, THD and the bandwith. And I have no idea what I am doing. I have got some numbers but I think it's all wrong (SNR=18,24dB, I dont think it should looks like this). It also look very short so I have to do somenthing wrong, something like everything. Can anyone tell me where I do mistakes? Thank you in advance.
Here is my code. I cut some data to make look this better (I had 100 samples, let's make only 10)
Code:
f = [0.0 256.0 512.0 768.0 1024.0 1280.0 1536.0 1792.0 2048.0 2304.0];
Lev_noise_input= [3.16e-02(TOTAL) 5.25e-03 2.57e-03 1.93e-03 2.40e-03 3.02e-03 3.51e-03 3.76e-03 4.57e-03 5.56e-03 ];
Lev_signal_input = [1.43e-02(TOTAL) 7.76e-05 2.69e-04 8.13e-03 1.43e-02 6.17e-03 1.86e-04 5.43e-05 1.86e-05 1.29e-05 ];
Lev_noise_output = [1.01e-03 9.89e-04 5.13e-04 4.12e-04 4.95e-04 5.50e-04 7.16e-04 8.22e-04 7.67e-04 7.50e-04];
Lev_signal_output=[5.89e-06 1.45e-05 4.37e-05 1.38e-03 2.40e-03 1.04e-03 3.27e-05 8.04e-06 4.22e-06 2.11e-06];
figure (1)
subplot(2,2,1)
plot(f, Lev_noise_input)
xlabel ('Frequency [Hz]')
ylabel ('Amplitude [V]')
title('Noise_input')
subplot (2,2,2)
plot(f, Lev_signal_input)
xlabel('Frequency [Hz]')
ylabel('Ambplitude [V]')
title ('Signal_input')
subplot(2,2,3)
plot(f, Lev_noise_output)
xlabel ('Frequency [Hz]')
ylabel ('Amplitude [V]')
title('Noise_output')
subplot (2,2,4)
plot(f, Lev_signal_output)
xlabel('Frequency [Hz]')
ylabel('Ambplitude [V]')
title ('Signal_output')
%SNR
P_signal = mean(Lev_sygnalu_input.^2);
P_noise = mean(Lev_szumu_input.^2);
SNR = P_signal/P_noise;
SNRdB= 10*log(SNR)
%Bandwith
DC_gain = Lev_sygnalu_output/Lev_sygnalu_input;
dB_gain = 20*log10(DC_gain)
dB_drop = max(dB_gain-3)
figure(2)
semilogx(f, dB_gain, 'sk-')
grid on;
xlabel('Frequency [Hz]');
ylabel('Gain [dB]')
title('Gain / Frequency');
fb = bandwidth(f, dB_drop)
%THD
FFT = abs(fft(Lev_sygnalu)).^2;
power_bin = min( find(FFT==max(FFT)));
signal_power = FFT(power_bin);
d_power = sum( [2 3 4 5 6]*power_bin );
THD = d_power/signal_power
THDdB= 10*log(THD)
Last edited by a moderator: