Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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 Kommentare
Scott Kaiser
Scott Kaiser am 31 Okt. 2023
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 am 31 Okt. 2023
@Scott Kaiser, Thanks for your clarification. Can you attach the look-up table so that we can test out @Matt J's suggestion?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Matt J
Matt J am 31 Okt. 2023
Bearbeitet: Matt J am 31 Okt. 2023
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 am 31 Okt. 2023
Bearbeitet: Catalytic am 31 Okt. 2023
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

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by