I need help obtaining the values c1,c2.c3 from a least squares fit of the data.

5 ビュー (過去 30 日間)
Lovie Reid
Lovie Reid 2020 年 7 月 29 日
編集済み: James Tursa 2020 年 7 月 30 日
I need help obtaining the values c1,c2.c3 from a least squares fit of the data.
  2 件のコメント
James Tursa
James Tursa 2020 年 7 月 29 日
What have you done so far? What specific problems are you having with your code?
Lovie Reid
Lovie Reid 2020 年 7 月 29 日
Ive plug in
K = [76.5 80.4 83.3 85.7 88.1 90.2 92.0 93.6 95.1 96.5 98.9];
MPa = [0.08 0.12 0.16 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.60];
y=log(MPa/3.77);
beyond this im confused as how to properly write out z

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

回答 (1 件)

James Tursa
James Tursa 2020 年 7 月 29 日
編集済み: James Tursa 2020 年 7 月 29 日
It appears to me that your equation is linear in c1, c2, c3. Just make a matrix equation out of this and then apply your least squares technique to the matrix. That is, you know everything in that equation except the c1, c2, c3. So just calculate all the values for each set of data and that will give you a matrix equation of the form:
b = A*c
where
each elemet of b is calculated from your data (the ln(Psat/Pc) values)
each row of A is calculated from your data corresponding to the element of b (the x, x^2, ln(Tsat/Tc) values)
c is simply the unknown column vector [c1;c2;c3]
Then use your least squares technique to solve for c.
  4 件のコメント
James Tursa
James Tursa 2020 年 7 月 30 日
Lovie Reid Answer moved here:
I've removed the ones(size(x)) I was just using other examples to help, but would this be right for the least squares
a = polyfit(x,y,2);
James Tursa
James Tursa 2020 年 7 月 30 日
編集済み: James Tursa 2020 年 7 月 30 日
polyfit(x,y,2) would be used if you had a set of x,y coordinates and you wanted to fit that with a 2nd degree polynomial. But you don't have that situation. You have a linear matrix equation with three variables that you are trying to fit. It is linear in the c1,c2,c3 terms. Using your variable names, you have this matrix equation (assuming you make y and x column vectors as I suggested):
y = z * c
You have three unknowns, the c = [c1;c2;c3], and 21 equations. An overdetermined linear system of equations where you know y and z. You are being asked to produce the least squares solution for c.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by