Curve fitting for power equation

2 次查看(过去 30 天)
Jay
Jay 2014-6-4
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
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
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.

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by