Multivariate Nonlinear Least Squares
31 次查看(过去 30 天)
显示 更早的评论
Morning everyone,
I've tried talking to MathWorks and playing with the tools in the curve fitting toolbox, but I can't seem to find a solution to my problem.
I have a model Y(P,W,L) = P^a * W^b *L^c + d where a, b, c and d are unknown coefficients I need to find. I have vectors for Y, P, W and L.
Please can you help me find a solution to this problem. I was told that the curve fitting toolbox was the way to go, but so far I haven't had any success setting up the model using fittype.
I would really appreciate a quick response to this problem as I need to have found a solution and reported my findings by this Friday.
Many thanks
0 个评论
采纳的回答
Star Strider
2016-7-27
I don’t have the Curve Fitting Toolbox, so I’m using fminsearch here:
P = randi(9, 10, 1); % Create Data
W = randi(9, 10, 1); % Create Data
L = randi(9, 10, 1); % Create Data
Y = randi(9, 10, 1); % Create Data
PWL = [P(:) W(:) L(:)]; % Create Single Variable
% % MAPPING: b(1) = a, b(2) =b, b(3) = c, b(4) = d
Y_fit = @(b,PWL) PWL(:,1).^b(1) + PWL(:,2).^b(2) + PWL(:,3).^b(3) + b(4);
SSECF = @(b) sum((Y(:) - Y_fit(b,PWL)).^2); % Sum-Squared-Error Cost Function
B0 = [1; 1; 1; 1]; % Initial Parameter Estimates
[B, SSE] = fminsearch(SSECF, B0); % Estimate Parameters
figure(1)
subplot(3,1,1)
plot(P, Y,'xr', P, Y_fit(B,PWL),'bp')
grid
subplot(3,1,2)
plot(W, Y,'xr', W, Y_fit(B,PWL),'bp')
grid
subplot(3,1,3)
plot(L, Y,'xr', L, Y_fit(B,PWL),'bp')
grid
I added the plots, since it usually helps me determine how good the fit is. If you want to plot your data and the regression, you will have to experiment with the plots, since they can be a bit difficult when you have three independent variables. The plotting I did here works, but it may not be the best for your data.
6 个评论
LANDON THOMAS KAMPS
2019-6-3
Thanks for the nice curve-fitting module.
This is working great for me too.
Much appreciated
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!