Curve fitting a function that is dependent on a difference of 2d functions
조회 수: 4 (최근 30일)
이전 댓글 표시
I have collected and plotted some data. The function I have plotted is the following:
for i=1:15
for j=i+1:15
DDTV_r0(i,j)=((D^(1/3)*((DTV(i)-DTV(j))))/(2*((cX(i)-cX(j))+(cY(i)-cY(j)))*.1816*Lambda^2))^(-3/5);
end
end
where DDTV_r0 is the value Im after. DTV on the right-side of the equation was calculated based on the data collected, and the rest of the variables are constants. DDTV_r0 has a theoretical value of (0.0025) for all valid combinations of (i,j) where j>i as shown in the for-loop. I would like to do some sort of curve fitting process that allows me to find what the values of DTV should be to get the theoretical DDTV_r0 values and compare those values to the DTV from my real data. What's confusing me is how to do this when DTV appears two times, as a difference, and the term (DTV(i)-DTV(j)) is constrained such that j>i. Im not sure how to handle this is the curvefitting toolbox. Any suggestions?
Here is an image of the plot for DDTV_r0(i,j) shown below from the data I collected. How do I use the curvefitting toolbox to create a similar plot for but for the theoritical values of DDTV_r0, and somehow give me the error between the fitted DTV values and the DTV from my data?
Thank you for any advice you can give!
댓글 수: 3
Sam Chak
2023년 10월 31일
@Scott Kaiser, Thanks for your clarification. Can you attach the look-up table so that we can test out @Matt J's suggestion?
답변 (2개)
Matt J
2023년 10월 31일
편집: Matt J
2023년 10월 31일
The Curve Fitting Toolbox is meant for fitting a small number of parameters. Here, you have 15 parameters, so you should use lsqcurvefit. lsqcurvefit doesn't care about the implementation details of the prediction function. You can put it inside a function that does whatever you need it to do.
upperTri=triu( true(15) ,1);
xdata={cX(:),cY(:),D,lambda,upperTri};
ydata=0.0025*ones(nnz(upperTri),1);
DTV = lsqcurvefit(@F, DTVguess, xdata,ydata);
DDTV0=F(DTV,xdata);
function pred=F(x,xdata)
DTV=x(:);
[cX,cY,D,lambda,upperTri]=deal(xdata{:});
Numerator=D^(1/3)*(DTV-DTV');
Denominator=2*( (cX-cX') + (cY-cY') )*.1816*Lambda^2;
DDTV_r0=(Numerator./Denominator).^(-3/5);
pred=DDTV_r0(upperTri);
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!