ploting coordinate smoothly with given dataset
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I want to draw the position of the object using vector x and y each containing coordinate of x and y with change in time.
To make the movement smooth using least square fitting, I p=polyval(x,y,60) and it returns:
Warning: Polynomial is badly
conditioned. Add points with distinct X
values, reduce the degree of the
polynomial, or try centering and scaling
as described in HELP POLYFIT.
the dataset is given so I can't change it. Please help
0 comentarios
Respuestas (1)
Cris LaPierre
el 8 de Dic. de 2020
Editada: Cris LaPierre
el 8 de Dic. de 2020
However, an n of 60 is a bit ridiculous. I would strongly recommend picking a value that is more appropriate for your data. At an absolute minimum, n cannot be great than your number of points. It should actually be much less than your number of points. Otherwise, you risk overfitting.
2 comentarios
Cris LaPierre
el 8 de Dic. de 2020
Unfortunately, I'm not aware of a good technique for smoothing data that is not a function (vertical line test).
I'm just googling here, but a couple options might be
% Circle points
x=10*cos(0:.07:6*pi);
y=10*sin(0:.07:6*pi);
% Add noise
x=x+rand(size(x))-.5;
y=y+rand(size(x))-.5;
plot(x,y,'.')
axis equal
xlim([-12 12])
ylim([-12 12])
% S-G filtering
windowWidth = 35;
polynomialOrder = 2;
smoothX = sgolayfilt(x, polynomialOrder, windowWidth);
smoothY = sgolayfilt(y, polynomialOrder, windowWidth);
hold on
plot(smoothX,smoothY,'or')
hold off
smoothX1 = smooth(x);
smoothY1 = smooth(y);
hold on
plot(smoothX1,smoothY1,'*g')
hold off
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!