Clear Filters
Clear Filters

HOW TO REMOVE NOISE FROM A SIGNAL?

3 views (last 30 days)
shahriar sowad
shahriar sowad on 3 Jul 2021
Commented: shahriar sowad on 4 Jul 2021
i have plotted a figure,here i am inckuding the code and files.Now,i want to smooth my output curve,how can i do it?
  2 Comments
Image Analyst
Image Analyst on 4 Jul 2021
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 15;
s = load('matlab.mat')
x0=reshape(b',[1,7001]);
t=linspace(0,1,7001);
Y=fft(b);
Yabs=abs(Y);
plot(Yabs,'b');
hold on
x1=reshape(d',[1,7001]);
t=linspace(0,1,7001);
Y1=fft(x1);
Y1abs=abs(Y1);
plot(Y1abs,'g');
x2=reshape(f',[1,7001]);
t=linspace(0,1,7001);
Y2=fft(x2);
Y2abs=abs(Y2);
plot(Y2abs,'r');
x3=reshape(h',[1,7001]);
t=linspace(0,1,7001);
Y3=fft(x3);
Y3abs=abs(Y3);
plot(Y3abs,'k');
x4=reshape(j',[1,7001]);
t=linspace(0,1,7001);
Y4=fft(x4);
Y4abs=abs(Y4);
plot(Y4abs,'y');
x5=reshape(l',[1,7001]);
t=linspace(0,1,7001);
Y5=fft(x5);
Y5abs=abs(Y5);
plot(Y5abs,'m');
plot([0 ,8000], [.05*10^4,.05*10^4],'k')
%yline(3.3614);
%yticks(unique([yticks(0.5) 3.3614]));
s =
struct with fields:
x3: [1×7001 string]
Unrecognized function or variable 'b'.
Error in test1 (line 11)
x0=reshape(b',[1,7001]);
So, what is b, d, f, and h, etc.? And where do you use x3 that came in from the mat file? You just create a new x3 from h and ignore the one from the mat file.
shahriar sowad
shahriar sowad on 4 Jul 2021
i am sorry for the previous file

Sign in to comment.

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 4 Jul 2021
You code contains some errs and moreover, your question to smooth the curve is not quite appropriate for FFT. In case, you need to smooth your data before FFT calcs, then it makes sense to apply some sort of low-pass or high-pass filter w.r.t what data component to preserve and diminish. Here is a sample code how to do it:
load matlab.mat
X3 = double(x3);
X=X3;
t=linspace(0,1,7001);
Fs = 1/t(2); % Sampling frequency
L = 7001; % Length of signal
Xfiltered=lowpass(x,200,Fs); % Low-pass to preserve the signal under 200 Hz
% Xfiltered=highpass(x,200,Fs); % High-pass to preserve the signal beyond 200 Hz
N = 2^nextpow2(L);
Y = fft(Xfiltered, N);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1, 'b'); grid on
title('Single-Sided Amplitude Spectrum of S(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')

Community Treasure Hunt

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

Start Hunting!