Smoothing curve plot with some data points
10 ビュー (過去 30 日間)
古いコメントを表示
hello, everybody
I have these data and I hope to plot them with smooth line.
Is it possible to create a smooth curve through these data points? I tried polybuffer function and it looks better.
But for data smoothing I failed using interpolation due to drastic chanhge of data points.
However, I think there is some ways I think. If possible please help me some.
x = [-27.59;-32.36;-32.36;-24.99;-25.12;-32.62;-37.62;-42.62;-37.62;-37.62;-40.11;-40.11;-37.61;-33.36;-29.11;-27.11;-25.11;-20.61;-14.36;15.64;45.64;158.76];
y = [-16.55;-16.55;-16.55;-16.62;-16.69;-16.69;-25.44;-34.19;-51.69;-51.69;-42.98;-42.98;-51.73;-60.48;-69.23;-70.48;-71.73;-81.73;-104.23;-126.73;-149.23;-149.23];
pgon = polybuffer([x y],'lines',2);
plot(pgon,'FaceColor','r','FaceAlpha',1,'EdgeColor','none')
% plot(x,y)
0 件のコメント
採用された回答
Jonas
2022 年 12 月 21 日
x = [-27.59;-32.36;-32.36;-24.99;-25.12;-32.62;-37.62;-42.62;-37.62;-37.62;-40.11;-40.11;-37.61;-33.36;-29.11;-27.11;-25.11;-20.61;-14.36;15.64;45.64;158.76];
y = [-16.55;-16.55;-16.55;-16.62;-16.69;-16.69;-25.44;-34.19;-51.69;-51.69;-42.98;-42.98;-51.73;-60.48;-69.23;-70.48;-71.73;-81.73;-104.23;-126.73;-149.23;-149.23];
subplot(1,2,1);
scatter(x,y,'ko')
hold on;
% you can try to use a sgolay filter directly on the data
smoothx=smooth(x,'sgolay');
smoothy=smooth(y,'sgolay');
plot(smoothx, smoothy)
dx=diff(x);
dy=diff(y);
factor=5;
interpx=cumsum([x(1); repelem(dx/factor,factor)]);
interpy=cumsum([y(1); repelem(dy/factor,factor)]);
% or you do some interpolation before to generate more point and change the
% parameters of the smooth function as needed
smoothx=smooth(interpx,15,'sgolay',2);
smoothy=smooth(interpy,15,'sgolay',2);
subplot(1,2,2)
scatter(x,y,'ko')
hold on;
scatter(interpx,interpy,'r.');
plot(smoothx, smoothy)
linkaxes()
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!