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
3 views (last 30 days)
Show older comments
Vidushi Koliyan
on 12 Apr 2023
Answered: Walter Roberson
on 12 Apr 2023
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
0 Comments
Accepted Answer
Walter Roberson
on 12 Apr 2023
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!