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

 채택된 답변

Star Strider
Star Strider 2016년 7월 27일

10 개 추천

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

jlt199
jlt199 2016년 7월 28일
Thank you very much! Your name is very apt because you are indeed a star!! :)
Star Strider
Star Strider 2016년 7월 28일
My pleasure! Thank you!
Pedro Machado
Pedro Machado 2018년 8월 9일
Simply the most useful info I have ever gotten. Thank you very much for the question, Jlt, and thank you so so much for the answer, Star.
Star Strider
Star Strider 2018년 8월 9일
@Pedro Machado —
My pleasure.
A vote for my Answer would be appreciated!
Thanks for the nice curve-fitting module.
This is working great for me too.
Much appreciated
Star Strider
Star Strider 2019년 6월 3일
@Landon —
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

질문:

2016년 7월 27일

댓글:

2019년 6월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by