필터 지우기
필터 지우기

Line approximation from 5 points in Matlab

조회 수: 4 (최근 30일)
Frank
Frank 2014년 12월 5일
답변: Frank 2014년 12월 5일
Hi, I would like to approximate a line in Matlab using 5 points with 5 x- and y-coordinates each.
I have two matrices as follows:
x = [365,672 526,974 593,972 660,972 819,974]
y = [249,996 250,001 250,005 250,007 250,0089]
I now would like to approximate a line that goes through these points. How do I accomplish that? I've tried Polyval and the "\-Operator", but that didn't quite work out. In the end, I need a function I could use later on.
Thanks!!

답변 (3개)

Orion
Orion 2014년 12월 5일
Hi,
interp1 is your friend

Torsten
Torsten 2014년 12월 5일
x = [365.672 ; 526.974 ; 593.972 ; 660.972 ; 819.974];
y = [249.996 ; 250.001 ; 250.005 ; 250.007 ; 250.0089];
A =[1 x(1); 1 x(2); 1 x(3); 1 x(4); 1 x(5)];
b=y;
l=A\b;
The line then has the equation g(x)=l(1)+l(2)*x .
Best wishes
Torsten.

Frank
Frank 2014년 12월 5일
Perfect, both are working!

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by