Hi, I have a set of 3D data points (x,y,z) that I want to fit using the equation
A*x^2+B*y^2+C*x*y = [ z (1-z) ]^2
A, B, C being the parameters I have to estimate.
can anyone help me?

 채택된 답변

Star Strider
Star Strider 2019년 4월 17일

0 개 추천

If your data points are each vectors, try this:
x = rand(1, 10); % Create Data
y = rand(1, 10); % Create Data
z = rand(1, 10); % Create Data
DM = [x(:).^2, y(:).^2, x(:).*y(:)]; % Design Matrix
P = DM \ (z(:).*(1-z(:))).^2; % Estimate Parameters
A = P(1);
B = P(2);
C = P(3)
Experiment to get the result you want.

댓글 수: 6

Alessandraro
Alessandraro 2019년 4월 18일
Thanks, the fact is now I changed the equation in
A*x^2+B*y^2+C*x*y = [ (z-D)/(1-D) (1-z) ]^2
A, B, C, D being the parameters I have to estimate.
Is it still possible to use your solution?
As always, my pleasure.
Is it still possible to use your solution?
Yes. The ‘P’ calculation then becomes:
P = DM \ [(z(:)-D(:))./(1-D(:)) (1-z(:))].^2; % Estimate Parameters
and ‘P’ is now a (3x2) matrix, so the parameters are now:
A = P(1,:);
B = P(2,:);
C = P(3,:);
Alessandraro
Alessandraro 2019년 6월 10일
Thank you for your answer. Can I, also, ask you how to evaluate the goodness of the fit? R^2?
As always, my pleasure.
I’m not certain which model you’re referring ot, so I calculated it for both:
x = rand(1, 10); % Create Data
y = rand(1, 10); % Create Data
z = rand(1, 10); % Create Data
D = rand(1, 10); % Create Data
DM = [x(:).^2, y(:).^2, x(:).*y(:)]; % Design Matrix
P = DM \ (z(:).*(1-z(:))).^2; % Estimate Parameters
SStot = sum(((z(:).*(1-z(:))).^2 - mean(z(:))).^2);
SSres = sum(((z(:).*(1-z(:))).^2 - DM*P).^2);
Rsq = 1 - SSres/SStot
P = DM \ [(z(:)-D(:))./(1-D(:)) (1-z(:))].^2; % Estimate Parameters
SStot = sum(([(z(:)-D(:))./(1-D(:)) (1-z(:))].^2 - mean(z(:))).^2);
SSres = sum(([(z(:)-D(:))./(1-D(:)) (1-z(:))].^2 - DM*P).^2);
Rsq = 1 - SSres/SStot
Alessandraro
Alessandraro 2019년 6월 12일
편집: Alessandraro 2019년 6월 12일
Thank you. I am sorry, can I ask you why you calculate SStot
SStot = sum(([(z(:)-D(:))./(1-D(:)) (1-z(:))].^2 - mean(z(:))).^2);
calculating mean(z(:)) instead of mean([(z(:)-D(:))./(1-D(:)) (1-z(:))].^2)?
Thank you.
Star Strider
Star Strider 2019년 6월 12일
Because that is how ‘SStot’ is calculated, at least as I interpret it in the context of yoiur model. See the Wikipedia article on: Coefficient of determination (link).

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품

릴리스

R2017b

태그

질문:

2019년 4월 17일

댓글:

2019년 6월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by