Curve fitting for power equation

how to fit curve for an equation y=a*(x1)^b * (x2)^c; where a b and c are constants to find and we do know sets f y x1 and x2?

답변 (2개)

David Sanchez
David Sanchez 2014년 6월 4일

0 개 추천

Use the curve fitting tool
cftool % this will open the curve fitting tool interface
From the user interface, select you x, y, z, data and insert your Custom Equation (the default method is Interpolant, change it in the selection list) The rest is almost straight forward.
Star Strider
Star Strider 2014년 6월 4일

0 개 추천

To fit your equation using fminsearch, this works:
% —————————— Define Function ——————————
PwrEqn = @(b,x) b(1) .* x(:,1).^b(2) .* x(:,2).^b(3);
% —————————— Create Data ——————————
b = [3 5 7]; % Parameters
x = rand(20,2); % Matrix of ‘x’ values
y = PwrEqn(b,x) + rand(20,1)*0.001; % Create ‘y’ using ‘PwrEqn’ and add noise
% —————————— Fit Data and Estimate Parameters ——————————
OLS = @(b) sum((y - PwrEqn(b,x)).^2);
b = fminsearch(OLS, [1 1 1]);
fprintf(1,'Estimated parameters:\n\ta = %.4f\n\tb = %.4f\n\tc = %.4f\n\n', b)
NOTE: Your x data have to be in one (Nx2) matrix (as [x1 x2]), and y as a (Nx1) vector.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

질문:

Jay
2014년 6월 4일

답변:

2014년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by