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
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 ?
回答(1 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!