Determining highest power frequency in noise signal

4 views (last 30 days)
I am a newbie to signal analysis with Matlab. I have voltage data in a CSV file. I want to use MatLab to identify the predominate frequency in the noise so I can design filtering to remove it. Generally, our SNR is ok for this application but sometimes we get big jumps in the noise and the SNR is not ok then. (We are simultaneously trying to figure out the source of this noise and eliminate it.)
I've tried to use some code posted by others in their questions but my results show that there isn't really a predominate frequency in the noise. But being a newbie, I'm not sure if I did this correctly. I would greatly appreciate review and comment to confirm that this is correct please.
The CSV data file is attached.
Here is my code...
T = readtable('{full path omitted}\Analog - 7-25-2022 2-41-32.623 PM for MatLab.csv','Delimiter',',');
plot(T.AI0)
T2 = T(65000:75000,:); % grab subset of readings where noise increases and SNR is unacceptable.
%plot(T2.AI0)
fs = 100; %sampling frequency
n = length(T2.AI0); % number of samples
T2.AI0 = T2.AI0 - mean(T.AI0);
Y = fft(T2.AI0);
P2 = abs(Y/n);
P1 = P2(1:n/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(n/2))/n; % frequency range
plot(f,P1)
Here is the first plot. This is the full data set.
Here is the subset of data.
Finally, here is the last plot.
It looks like the highest power is at 0 (DC). If I could remove it, then I'd potentially see some of the other frequencies at higher powers but still nothing that just stands out as a major player.
I appreciate any help or thoughts on this! Again, a newbie so please be kind.
  2 Comments
dpb
dpb on 26 Jul 2022
To zero out the DC, simply subtract mean(x) -- but it won't make any difference to any of the other frequencies.
I didn't see how long your signal is, a good way to reduce the effect of random noise is to average over the full time series taking some fraction of the data (1/16th) or so each pass...the systematic frequencies will be reinforce but the truly random stuff will average out to reduce their contribution leaving a better estimate of what is real.

Sign in to comment.

Answers (1)

Paul
Paul on 27 Jul 2022
Edited: Paul on 27 Jul 2022
Hi Walter,
The original code in the question subtracted the mean of the entire signal (T), not the mean of just the portion to be analyzed (T2), which results in that big peak at 0. Also, in the code below I just plotted the output of FFT, because it sounds like you're just trying to find the dominant frequencies, so that other scaling (divide by n, mutliply by 2) doesn't really do anything in a relative sense.
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1078245/Analog%20-%207-25-2022%202-41-32.623%20PM%20for%20Matlab.csv','Delimiter',',');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
figure
plot(T.AI0)
T2 = T(65000:75000,:); % grab subset of readings where noise increases and SNR is unacceptable.
figure
plot(T2.AI0)
fs = 100; %sampling frequency
n = length(T2.AI0); % number of samples
%T2.AI0 = T2.AI0 - mean(T.AI0);
T2.AI0 = T2.AI0 - mean(T2.AI0);
Y = fft(T2.AI0);
%P2 = abs(Y/n);
%P1 = P2(1:n/2+1);
%P1(2:end-1) = 2*P1(2:end-1);
%f = fs*(0:(n/2))/n; % frequency range
f = (0:(n-1))/n*fs;
figure
plot(f,abs(Y))
xlim([0 50])
Can also experiment with functions like spectrogram to try and see how the frequencies change with time.
figure
spectrogram(T.AI0-mean(T.AI0),128,[],128,fs);
xlim([0 50])
  1 Comment
Walter Cromer
Walter Cromer on 27 Jul 2022
Thank you so much! This has been very helpful and it is giving me what I was looking for now! I appreciate your kind assistance!

Sign in to comment.

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!