Hello everyone, anyone knows how to approximate a data with polynomial of degree 8 using least square method?

조회 수: 1 (최근 30일)
Polynomial degree is 8 and it should be approximated piecewise.
  • y = a0t0 + a1t1 + a2t2 + + antn ………………………….. (1)
Data description:
The first column is Time(GPS format) unit is seconds.
Second column is y values, so I have to find the coefficients (a0, a1...). And this should be done peicewise (9 points), then iterate this method till the end of the data.
Data is attached.
  댓글 수: 5
Mohammad Shafi Nikzada
Mohammad Shafi Nikzada 2021년 6월 25일
This is what our assistant prof. wants. Find the coefficients, plug it into the equation and then calculate Velocity and acceleration. :D
Matt J
Matt J 2021년 6월 25일
편집: Matt J 2021년 6월 25일
Your data looks very sinuisoidal. Are you sure you couldn't convince your assistant prof. just to fit a sinusoid?

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2021년 6월 25일
Loop, moving one point at a time. At each location use polyfit on 9 points to create coefficients. polyder() https://www.mathworks.com/help/matlab/ref/polyder.html and evaluate to get velocity. polyder() again and evaluate to get acceleration.
Then move one point further on.

David Hill
David Hill 2021년 6월 25일
편집: David Hill 2021년 6월 25일
Use polyfit, place the x and y columns of your data into the function.
p=polyfit(x,y,8);%you will need to convert time using datenum and likely normalize

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by