Solve a matrix system generated at runtime

1 回表示 (過去 30 日間)
Andrew Farsech
Andrew Farsech 2016 年 5 月 29 日
コメント済み: John D'Errico 2016 年 5 月 29 日
I have a matrix with 31 rows and 4 columns
I want to find the values of unknown parameters a, b, c that multiplied for the other columns minimize the difference between first columns and the rest of the matrix according this formula:
matrix(i,1)=a*matrix(i,2)+b*matrix(i,3)+c*matrix(i,4)+(gam1+gam2*matrix(i,4))
(gam1 and gam2 are 2 constants that I already know, and i is the row index)
Matlab seems doesn't like undefined variables. What is the syntax that I have to use?

回答 (1 件)

John D'Errico
John D'Errico 2016 年 5 月 29 日
abc = matrix(:,2:4)\(matrix(:,1)-gam1-gam2*matrix(:,4));
  2 件のコメント
Andrew Farsech
Andrew Farsech 2016 年 5 月 29 日
編集済み: Andrew Farsech 2016 年 5 月 29 日
Thanks for the answer. could you clarify me? Doesn't seem work. I need all a, b, c parameters separately.
John D'Errico
John D'Errico 2016 年 5 月 29 日
It honestly does not work? Did you try it? Is it really that difficult to write:
a = abc(1);
b = abc(2);
c = abc(3);
Perhaps it is time to learn how to use vectors in MATLAB?

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by