Curve fitting a function that is dependent on a difference of 2d functions

조회 수: 4 (최근 30일)
Scott Kaiser
Scott Kaiser 2023년 10월 31일
편집: Catalytic 2023년 10월 31일
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
Scott Kaiser
Scott Kaiser 2023년 10월 31일
You may have trouble plotting since (cX(i)-cX(j))+(cY(i)-cY(j) are all each from a look-up table. Is this the issue you are having?
Sam Chak
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
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

Catalytic
Catalytic 2023년 10월 31일
편집: Catalytic 2023년 10월 31일
There appears to be a simple analytical solution -
constant=(0.0025)^(-5/3)*(2*Lambda^2*0.1816)/D^(1/3);
DTV=(cX+cY)*constant

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by