Smoothing curve plot with some data points
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Smithy
el 21 de Dic. de 2022
Comentada: Smithy
el 21 de Dic. de 2022
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 comentarios
Respuesta aceptada
Jonas
el 21 de Dic. de 2022
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()
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!