MATLAB Answers

How can I subtract two WAV audio FFT signals?

31 views (last 30 days)
Hello MATLAB community,
Below, you will find 2 WAV files. One is the background noise and the other is the signal obtained during the experiment. I am interested in the 0-1000 Hz frequency range and as you can see in the below image, I figured out how to overlay 2 FFT's in 1 graph.
Now, I want to delete "noise FFT signal" from the "experimental FFT signal". Can I somehow subtract directly in the "Figure Window"? or I need to write an additional code?
In the example shown below, you can see a strong peak around 350 Hz, which I am looking at and by subtracting it from the background noise, I would get a smooth curve and obtain a raw experiment signal.
Finally, when I subtract 2 graphs, I could get just data points on the plot, which I want to join in a smooth line.
Thank you.
%clear, clc, close all
% Nfft = length of fft
%X = the fft of the samples y in 8192 points
%title('Combine Plots')
%2nd graph begins
hold on
% Nfft = length of fft
%X = the fft of the samples y in 8192 points
ylabel ('Amplitude');
title ('Background noise & experiment signals overlayed');
hold off

Accepted Answer

Kiran Felix Robert
Kiran Felix Robert on 13 Jul 2021
Hi Avinash,
You can easily use a one line script to subtract the curves.
The data points in the plot functions are
plot1_x = f1(1:Nfft/2);
plot1_y = X1(1:Nfft/2);
plot2_x = f2(1:Nfft/2);
plot2_y = X2(1:Nfft/2);
If f1 and f2 are of the same length, then you can perform the following operation to subtract,
difference = plot1_y - plot2_y;
You can plot using the following code,
If the vectors are not of equal length, you can always pad zeros to the end of the smaller length signal.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by