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 日間)
SOURANGSU
SOURANGSU 2013 年 12 月 6 日
回答済み: Image Analyst 2013 年 12 月 7 日
slope of line formed by arbitary points
  1 件のコメント
Image Analyst
Image Analyst 2013 年 12 月 7 日
Those aren't "points" - it's only the x or only the y values. Please supply actual 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 ...
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 6 日
If coordinates are not given, we suppose they are equally spaced.

サインインしてコメントする。


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 Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by