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!