ploting coordinate smoothly with given dataset
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Cris LaPierre
2020년 12월 8일
편집: Cris LaPierre
2020년 12월 8일
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
Cris LaPierre
2020년 12월 8일
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
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!