How to smooth the data using the MATLAB?
Show older comments
Hi
I was trying to smaooth the data using smooth function but not able to manage. can some experties help me. the data is attached here.
Thank you in advance!
Accepted Answer
More Answers (1)
Image Analyst
on 9 Jun 2022
Here are some options. Median filter medfilt1 and Savitzky Golay filter sgolayfilt. Adjust window widths as desired.
data = readmatrix('data1.txt')
x = data(:, 2);
y = data(:, 1);
plot(x, y, 'b-', 'LineWidth', 2);
grid on;
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
% Smooth the data
smoothedMedian = medfilt1(y, 79);
hold on;
plot(x, smoothedMedian, 'g-', 'LineWidth', 4);
smoothedSG = sgolayfilt(y, 2, 201);
hold on;
plot(x, smoothedSG, 'r-', 'LineWidth', 3);
legend('Original', 'Median', 'Savitzky-Golay')

1 Comment
Somnath Kale
on 9 Jun 2022
Categories
Find more on Smoothing and Denoising 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!