How to remove harmonics and noises from a signal and reconstruct it?

39 visualizzazioni (ultimi 30 giorni)
I have a downsampled sinusoidal signal. Then signal has 32 samples per cycle. It contains harmonics (upto 13th) as well as noises. The actual snusoidal signal is . How can I get the actual sinusoidal signal by removing the harmonics and noises. I have to do it in m.file.
  2 Commenti
Jonas
Jonas il 7 Lug 2023
what about using a lowpass to remove any harmonics and the noise? which kind of noise is present?

Accedi per commentare.

Risposte (1)

William Rose
William Rose il 10 Lug 2023
Modificato: William Rose il 10 Lug 2023
[edit: correct spelling errors]
Make a signal with 32 samples per cycle, and smaller sinusoids at the 2nd, 7th, and 13th harmonic, and noise.
ff=1; % fundamental frequency (Hz)
A=195; % amplitude of fundamental
fs=32*ff; % sampling rate (Hz)
nc=5; % number of cycles of fundamental
sd=A/10; % noise st.dev.
N=nc*fs; % signal length (points)
t=(0:N-1)/fs; % time vector (s)
xf=A*sin(2*pi*ff*t); % fundamental sinusoid
x=xf+(A/2)*sin(2*pi*ff*2*t)+(A/2)*sin(2*pi*ff*7*t)... % fundamental+2nd+7th harmonic
+(A/2)*sin(2*pi*ff*13*t)+sd*randn(1,N); % + 13th harmonic + noise
plot(t,x,'-r.', t, xf,'-g.');
grid on; xlabel('Time (s)'); ylabel('Amplitude')
The total signal and the fundamental frequency sinusoid are plotted.
[b,a]=butter(2,.1); % Butterworth lowpass filter, 2 pole, normalized cutoff frequency=0.1
y=filtfilt(b,a,x); % filter the signal
hold on; plot(t,y,'-b.'); % add filtered signal to plot
legend('Total Signal','Fundamental Sinusoid','Filtered Signal')
The blue trace is the filtered signal. We hope that it will look like the green signal. The last cycle of the filtered signal is weird, due to edge effects, but the preceding cycles are pretty similar to the green trace. Not perfect but not terrible.
Try changing the filter order (from 2 to 3-8) and the cutoff frequency (from 0.1 to a number between 0 and 1) in the line
[b,a]=butter(2,.1);
and see if you like the results better than the results above.

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by