fit accuracy using custom equation
7 ビュー (過去 30 日間)
i'm using this code to show the data in the .txt file and then i'm using the fitting app on matlab using a custom equation and i particular i'm using this model here:
for the previous value in temperature the fit seems more than fine but for data on lower Temperature seems like it's not fitting quite well, seems like it's been shifted below
do you have any suggestions on how to modify some parameters or maybe trying using another equation?
%Importare dati, indicare percorso file dati completo
xdata=ST_n_180K(:,1); % v (riga, colonna)
ydata=ST_n_180K(:,2); % i (riga, colonna)
title('fit IvsV a 180K')
回答 (1 件)
John D'Errico 2023 年 8 月 30 日
編集済み: John D'Errico 2023 年 8 月 30 日
First, the model you show is not even a valid expression. The parens don't match up.
2 left parens, 3 right parens. And I have no idea what you intend by that expression.
Next, below V==0, the response is esssentially constant, while slightly negative. There is essentially no information content in that part of the data. It seems to be vaguely oscillating, but the model you show should not do so, regardless of the placement of a spare parens.
MAYBE you intend this basic model:
y=a*log(1+exp(x/b)) - c
which would be a valid expression. But it will not have quite the shape you see in that data, though it is not too far off. For example, if I just replace each of those parameters by 1, we would see this fundamental shape:
fplot(@(x) 1*log(1+exp(x/1)) - 1)
And there we see a curve which is asymptotically linear at both ends of the curve, looking like a hyperbola. But your data does not seem to be straightening out on the top end. And it has a clear break in curvature right at V==0. Both of those things are inconsistent with the model I would guess is the one you have chosen. Instead, you might as easily have chosen a simpler model. For example, loading your data, we see this:
xy = textread('ST_n_180K.txt');
x = xy(:,1);
y = xy(:,2);
k = x>=0;
A log plot will tell me what I sort of suspect to be the case. (Ok, a loglog plot would suggest a power law model is probably most appropriate here. But the exponential will work as well.)
Do you see this curve is very near linear? And the fact that it is very close to linear at the top end tells me it is NOT becoming asymptotic to a straight line at all. That suggests a simple model for the right half of the curve is just a basic exponential, of sorts. I could use expm1, or just its expression using exp. And the left half of the curve is just a constant. So we might do this.
mdl = fittype('a + b*(exp(max(x,0)/c)-1)','indep','x');
fittedmdl = fit(x,y,mdl,'start',[-.01,1,1])
The fit is not too terrible. The only significant lack of fit happens in the curvature just above zero. I might try to repair that in various ways, were that a problem. Perhaps we might include an extra parameter as the break point between the separate pieces. If I do that, then we see the lack of fit has almost totally gone away.
mdl2 = fittype('a + b*(exp(max(x,d)/c)-1)','indep','x');
fittedmdl2 = fit(x,y,mdl2,'start',[-.01,1,1,.25])
I doubt its worth the effort of trying to squeeze much more out of that data. But, in my quest to squeeze every drop of blood from the proverbial rock, try a modified power law model. It would look like this:
mdl3 = fittype('a + b*max(x,0).^c','indep','x');
fittedmdl3 = fit(x,y,mdl3,'start',[-.03,.5,3])
And that too seems to fit quite reasonably well, possibly better than the exponential form I chose for mdl2. Feel free to choose between forms as you please. A quick comparison of the residuals suggests little to choose between model forms 2 and 3.
plot(x,fittedmdl(x) - y)
plot(x,fittedmdl2(x) - y)
plot(x,fittedmdl3(x) - y)