필터 지우기
필터 지우기

Suppose i have points ( 0.9, 79, 76,23, 1, 3, 4.3,89), what is the slope of the line formed by this points

조회 수: 1 (최근 30일)
slope of line formed by arbitary points

답변 (4개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 6일
These points don't form one line. Maybe you need to use a curve fitting toolbox to fit a function ax+b
  댓글 수: 2
John D'Errico
John D'Errico 2013년 12월 6일
ax+b IS the equation of a straight line. How will the curve fitting toolbox fit a straight line any better than any other fitting tool? Magic?
Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 6일
Jhon, I have not said it's a better way, just proposed a solution with (maybe). what is yours?

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


Wayne King
Wayne King 2013년 12월 6일
편집: Wayne King 2013년 12월 6일
You have not told us what the "x"-values are. If we assume that they are
y = [0.9, 79, 76,23, 1, 3, 4.3,89];
x = 1:length(y); % 1 to 8
You can only fit a least-squares line to this data in order to measure the slope.
X = ones(length(y),2);
X(:,2) = 1:length(y);
y = y(:);
X\y
The intercept is 34.4071 and the slope is 0.0262, but that is a very poor approximation to the data.

Jos (10584)
Jos (10584) 2013년 12월 6일
편집: Jos (10584) 2013년 12월 6일
help polyfit
Note that points are usually defined by coordinates and not by single numbers ...

Image Analyst
Image Analyst 2013년 12월 7일
Try polyfit() to fit (regress) a line through some (x,y) coordinates:
coefficients = polyfit(x, y, 1);
slope = coefficients(1);

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by