solving coefficient with linear algebra

1 回表示 (過去 30 日間)
Nicholas Deosaran
Nicholas Deosaran 2020 年 9 月 15 日
編集済み: James Tursa 2020 年 9 月 15 日
How can I determine the coefficients, p, of the least squares fit of a plane through the data defined as:
data = p(1) + p(2)*x + p(3)*y.
Useing the data given by the following code.
x=1:10;
y=x;
[X,Y]=meshgrid(x,y); % make a grid of x and y
valuesX=X(:); % turns the matrix into a long vector instead
Y=Y(:); % turns the matrix into a long vector
insteaddata=cumsum(ones(10,10))+(1-rand(10,10)); % fake elevation data
data=data(:); % turns the matrix into a long vector instead

回答 (1 件)

James Tursa
James Tursa 2020 年 9 月 15 日
編集済み: James Tursa 2020 年 9 月 15 日
You basically have this:
[ONES_COLUMN, X_COLUMN, Y_COLUMN] * p = DATA
You know all the CAPS stuff. So just use the standard least squares solution to find p. I.e., if you had the generic problem A*x = b, how would you find the least squares solution for x?

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by