Clear Filters
Clear Filters

want to remove extra data in fft data set

2 views (last 30 days)
Ambesh
Ambesh on 8 Feb 2024
Answered: Pooja Kumari on 8 Feb 2024
i have a current and diffrentioan dat form of magnetic field. those have some extra unwanted error in them. so by doing fft i wnat to remove them.

Answers (1)

Pooja Kumari
Pooja Kumari on 8 Feb 2024
Hello ambesh,
I think you wanted to remove the extra unwanted error by using fft function.
You can refer to the below code for your reference:
% Assuming you have your current and differential data in vectors
current_data = []; % Your current data
diff_data = []; % Your differential data
% Perform FFT
current_fft = fft(current_data);
diff_fft = fft(diff_data);
% Determine the frequencies for each bin
n = length(current_data); % Assuming current and diff data are the same length
Fs = 1000; % Your data's sample rate in Hz
freqs = (0:n-1)*(Fs/n);
% Apply filter by setting unwanted frequencies to zero
cutoff_frequency = 50; % I have taken Low-pass filter
% Create a mask for frequencies that are within the desired range
mask = (freqs < cutoff_frequency) | (freqs > (Fs - cutoff_frequency)); % Low-pass filter mask
% Apply the mask to the FFT data by element-wise multiplication
filtered_current_fft = current_fft .* mask;
filtered_diff_fft = diff_fft .* mask;
% Perform the inverse FFT to get the cleaned up signal
cleaned_current_data = real(ifft(filtered_current_fft));
cleaned_diff_data = real(ifft(filtered_diff_fft));
You can refer to the following documentation for more information on fft function:

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!