I want to solve this equation for a and b where A and B is a vector data with dimension (1344x1) A=a(B)^b

1 次查看(过去 30 天)
Here; A = data1 ; B = data2
y = data1;
Y = log(y);
A = [ones(length(y),1) log(data2)'];
X1 = inv(A'*A);
X2 = A'.*Y;
X = X1*X2;
a = exp(X(1:1,1));
b = X(2,1:1);
this is the method I am using to solve for this equation. But I am not sure this is the right way to solve nonlinear equations. Can someone suggest an alternate way with an example?
Thank you

采纳的回答

Walter Roberson
Walter Roberson 2023-4-12
p = polyfit(log(B), log(A), 1);
a = exp(p(2));
b = p(1);
This would at least be a good starting point for a search in linear space (it should be close to as good as you can get in log space.)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by