Here is all codes, I could not find how and where to add ‘20*log(Vout/Vin)’ equation to convert voltage values to dB units. If there are other ways to do that I would like to listen and know.
clc;clear all;close all;
pkg load io;
pkg load signal;
Data1 = xlsread(‘numunelik2.xlsx’);
D = Data1(:,1); %Voltage value
T = Data1(:,2); % Time data
Ts = 0.004; % Sampling Interval (s)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency
LF = size(D,1); % Length of Data Vector
figure(1) % Plot Data
plot(T, D)
xlabel(‘Time(µs)’);
ylabel(‘Voltage(V)’);
grid
FF = fft(D)/LF; % Fourier Series of Data, Freq Vector
Fv = linspace(0,1,fix(LF/2)+1)*Fn;
Iv = 1:length(Fv); % Index Vector
figure(2); % Plot FFT
plot(Fv, abs(FF(Iv)))
grid
xlabel(‘Frequency (Hz)’)
ylabel(‘Power(dB)’)
axis([0 130 ylim]);