how to determine constants for a given equation to fit data?

Hi, I have a 21*4 matrix, the first column data is dependent value H, the last three columns are for three different INDEPENDENT variables G,W,M. How can I find the optimized constants A1,A2,A3 which MAY fit a given equation : H=A1*(G*W*M)^A2+A3?
Thanks in advance. Joe

 Accepted Answer

use nlinfit from Statistics Toolbox.
A - your array [21x4]
out = nlinfit(prod(A(:,2:end)),A(:,1),@(a,x)a(1)*x.^a(2)+a(3),[1 1 1]);

3 Comments

you seems to treat the three variables as one (G*W*M), what if the given equation change to H=A1*G*W*[1-exp(A2/M)]+A3?
try
out = nlinfit(prod(A(:,2:end)),A(:,1),@(a,x)a(1)*prod(x(:,2:3),2).*(1-exp(a(2)./x(:,4))+a(3),[1 1 1]);
and please read:
doc nlinfit

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!