Fit sum parameters of an overdetermined system

조회 수: 4 (최근 30일)
Marco Knobloch
Marco Knobloch 2019년 12월 11일
댓글: Marco Knobloch 2019년 12월 12일
I have a function that uses 9 inputs (cts(1) to cts (9)) and provides 1 value as result. The function needs 4 parameters (c(1) to c(4)). The code of the function is:
fun = @(c,cts) ((c(1) .* (4-c(4))) ./ (c(2)+c(3) .* 4)) *cts(1) +...
((c(1) .* (5-c(4))) ./ (c(2)+c(3) .* 5)) *cts(2)+ ...
((c(1) .* (6-c(4))) ./ (c(2)+c(3) .* 6)) *cts(3) + ...
((c(1) .* (7-c(4))) ./ (c(2)+c(3) .* 7)) *cts(4) + ...
((c(1) .* (8-c(4))) ./ (c(2)+c(3) .* 8)) *cts(5) + ...
((c(1) .* (9-c(4))) ./ (c(2)+c(3) .* 9)) *cts(6) + ...
((c(1) .* (10-c(4))) ./ (c(2)+c(3) .* 10)) *cts(7) + ...
((c(1) .* (11-c(4))) ./ (c(2)+c(3) .* 11)) *cts(8) + ...
((c(1) .* (12-c(4))) ./ (c(2)+c(3) .* 12)) *cts(9)
I have 11 measured values with each 9 inputs. From this data set I want to fit the parameters c. Is there an algorithm which I can use for this problem? I already tried lsqcurvefit, but that atempt ended with the error:
Error using lsqcurvefit (line 263)
Function value and YDATA sizes are not equal.

채택된 답변

Matt J
Matt J 2019년 12월 11일
편집: Matt J 2019년 12월 11일
Your xdata should be a 9x11 matrix, your ydata should be a 1x11 vector, and the code for your function should look like this,
fun = @(c,cts) ((c(1) .* (4-c(4))) ./ (c(2)+c(3) .* 4)) *cts(1,:) +...
((c(1) .* (5-c(4))) ./ (c(2)+c(3) .* 5)) *cts(2,:)+ ...
((c(1) .* (6-c(4))) ./ (c(2)+c(3) .* 6)) *cts(3,:) + ...
((c(1) .* (7-c(4))) ./ (c(2)+c(3) .* 7)) *cts(4,:) + ...
((c(1) .* (8-c(4))) ./ (c(2)+c(3) .* 8)) *cts(5,:) + ...
((c(1) .* (9-c(4))) ./ (c(2)+c(3) .* 9)) *cts(6,:) + ...
((c(1) .* (10-c(4))) ./ (c(2)+c(3) .* 10)) *cts(7,:) + ...
((c(1) .* (11-c(4))) ./ (c(2)+c(3) .* 11)) *cts(8,:) + ...
((c(1) .* (12-c(4))) ./ (c(2)+c(3) .* 12)) *cts(9,:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by