noise reduction in matlab

There are several techniques to perform noise reduction in Matlab. One common method is to use digital filters to remove noise from the signal. Here is an example of how to use a low-pass filter to reduce high frequency noise:

main.m
% Generate a noisy signal
t = 0:0.001:1;
x = sin(2*pi*50*t) + randn(size(t));

% Create a low-pass filter
fc = 100; % cutoff frequency
fs = 1000; % sampling frequency
[b,a] = butter(2,fc/(fs/2));

% Apply the filter to the signal
y = filter(b,a,x);

% Plot the results
figure;
plot(t,x);
hold on;
plot(t,y);
legend('Noisy signal','Filtered signal');
350 chars
19 lines

In this example, a noisy sine wave is generated and a second-order Butterworth filter is used to remove the noise. The resulting filtered signal is then plotted along with the original noisy signal. You can adjust the filter parameters to obtain different levels of noise reduction.

gistlibby LogSnag