Measure EMI with FFT from oscilloscope data

7 views (last 30 days)
hello, I trying to write a code where i can transfer the data from a oscilloscope to matlab in order to see my electromagnetic interference (EMI) on a dBuv/Hz plot.
clear
opts = detectImportOptions("C1--Trace--00000.csv");
opts.DataLines = [ 6 inf ];
t = readmatrix("C1--Trace--00000.csv",opts);
o = length(t);
n = 1;
k= 100000;
F = zeros(100000,1);
iterCount = 0;
Ts = mean(diff(t(:,1)));
Fs = 1/Ts;
Fn = Fs/2;
while k < o
t1 = t(n:k,2);
F = F + t1;
n = n + 100000;
k = k + 100000;
iterCount = iterCount + 1;
tot = F/iterCount;
end
LF = length(tot);
FF = fft(tot)/LF;
Fv = linspace(0,1,fix(LF/2)+1)*Fn;
Iv = 1:length(Fv);
dBuV = 20*log10(FF)+120;
figure
plot(Fv, abs(dBuV(Iv)));
xlabel('Frequency (Hz)')
ylabel('Amplitude dBuV')
set(gca, 'XLim',[150e3 3e7])
set(gca,'xscale','log')
grid
When I started to work on my code it was suggested to me that i could be using a loop and limit the samples because the overall samples on the first data i got was around 60 million samples but the later one was limited to 5 million.
Running my code now the plot show too big of a difference when changing the "k" value that i was wondering if it is even possible to use it or if im just implementing it incorrectly.
I would love some input and if some other overall improvement could be done to improve my code since it is pretty bareboned.
Does anyone have any suggestions on how to upload my csv file of the data? I wanted to upload my csv file but the file is too large even when i turn it into a zip. I was thinking about opening it and dividing it into multiple files but excel cant even open the entire file.

Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!