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?

Antworten (2)

David Sanchez
David Sanchez am 4 Jun. 2014

0 Stimmen

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 am 4 Jun. 2014

0 Stimmen

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.

Kategorien

Gefragt:

Jay
am 4 Jun. 2014

Beantwortet:

am 4 Jun. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by