How to smooth the data using the MATLAB?

2 ビュー (過去 30 日間)
Somnath Kale
Somnath Kale 2022 年 6 月 9 日
コメント済み: Somnath Kale 2022 年 6 月 9 日
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!

採用された回答

KSSV
KSSV 2022 年 6 月 9 日
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1026350/data.txt');
x = T.Var2 ;
y = T.Var1 ;
yy = smooth(x,y,20) ;
plot(x,y,'r',x,yy,'b')
  1 件のコメント
Somnath Kale
Somnath Kale 2022 年 6 月 9 日
Thank You for your swift response

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 6 月 9 日
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 件のコメント
Somnath Kale
Somnath Kale 2022 年 6 月 9 日
@Image Analyst Thank You for you little advance smoothing functions information! I will look to that as well.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by