필터 지우기
필터 지우기

how to fit a curve to 3 points automatically?

조회 수: 15 (최근 30일)
Marry M
Marry M 2016년 3월 2일
답변: Torsten 2016년 3월 3일
Guys, I'd like to find an automatic method for fitting y=-x^2 curve to three points x=[12 67 16]; can any one suggest me a matlab code please?
  댓글 수: 5
Jos (10584)
Jos (10584) 2016년 3월 2일
What are the parameters you want to estimate? Fitting a curve involves finding values for one or more unknown parameters, like finding A and B in the equation Yfit = A*x^2 + B that minimises the overal "distance" between the known values of y and the fitted values Yfit
Marry M
Marry M 2016년 3월 2일
attached a sample what i meant, is it possible for me to find a cure like in the photo (red) fitted 3 points (back here)? if so, how? thanks alot

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

채택된 답변

Torsten
Torsten 2016년 3월 3일
Maybe something like
A=[x1^2 x1 1
x2^2 x2 1
x3^2 x3 1];
rhs=[y1 ; y2 ; y3];
sol=A\b;
func=@(x)sol(1)*x.^2+sol(2)*x+sol(3);
x=x1:0.1:x2;
y=func(x);
plot(x,y)
where (x1,y1), (x2,y2), (x3,y3) are the points in question ?
Best wishes
Torsten.

추가 답변 (1개)

Jos (10584)
Jos (10584) 2016년 3월 2일
FT = fittype('a*x^2')
MDL = fit(x(:),y(:),FT)
MDL.a

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by