how to solve a system of linear equation in matlab for gridded data

2 次查看(过去 30 天)
I have a linear equation log(P) -log(diff(S)/dt) =log(z) + log(a)+ b*log(S) and gridded values for log(P),log(diff(S)/dt) and log(S) of size 364x9. in which 364 stands for no of days and 9 stands for the no of grids . so i have to solve the above equation for 9 grids to get a, b and z for the available grds in matlab
  4 个评论
Torsten
Torsten 2023-5-21
z and a cannot be solved for separately. So you have 2 unknowns, namely log(az) and b.
And you have 364 x 9 measurement data for 2 unknowns ? Did I understand this correctly ?
log(P(i,j)) - log(diff(S)/dt(i,j)) = log(az)+ b*log(S(i,j))
for 1 <= i <= 364 and 1 <= j <= 9 ?
FATHIMA JAMSHEENA P
z, a and b are unknown parameters and for finding them we have to use the above given relation in which P and S data of size 364x9 are available. so if we construct a forloop to find these parameters we have to get a, b and z data of size 9*1 as solution.

请先登录,再进行评论。

回答(1 个)

Torsten
Torsten 2023-5-22
编辑:Torsten 2023-5-22
As said, you can't estimate z and a separately. Say you have
y = z + a
and data for y. Say you get z = 4 and a = 2 as solution. Then all combinations of z and a with z + a = 6 would be solutions, too. One says that the problem is overfitted.
If you want to get solutions for the revised problem, use
for i = 1:9
A = [ones(364,1) log(S(:,i))];
b = log(P(:,i))-log(gradient(S(:,i)));
sol = A\b;
za(i) = sol(1);
b(i) = sol(2);
end
I assume that the unit per days for dS/dt is correct. Otherwise, you will have to scale gradient(S(:,i)) by the correct unit.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by