# fit accuracy using custom equation

7 ビュー (過去 30 日間)
federico 2023 年 8 月 30 日
コメント済み: federico 2023 年 8 月 31 日
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:
y=a*log(1+exp(x/b))-c)
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)
%plot dati
plot(xdata,ydata,'ro');
title('fit IvsV a 180K')
xlabel('V [V]');
ylabel('I [mA]');
##### 2 件のコメントなしを表示なしを非表示
federico 2023 年 8 月 30 日
fig.1: 180K
fig.2: 260K
my bad on the parens, i must have wrote that bad and copied that aswell.
the question was about the equation to evaluate the best fit for this model of a Schottky type diode.
as shown in fig.1 the plot i'm referring to in the first question not being good.
but it works for the one at 260K in fig.2.
my question is still about the equation to fit the model, taking any suggestions on how to modify it to make it work on other temperatures.
John D'Errico 2023 年 8 月 30 日
As I point out in my answer, the data does not support the model you want to use. I did guess correctly about where you wanted the parens.
That model is asymptotivally linear for large inputs. However, your data does not appear to have that shape, as it is growing smoothly, and not slowing down in its rate of growth.
This suggests either the model I chose in my answer, or a power law model which might fit too. I did not try the latter, since the former works quite nicely.

サインインしてコメントする。

### 回答 (1 件)

John D'Errico 2023 年 8 月 30 日

First, the model you show is not even a valid expression. The parens don't match up.
y=a*log(1+exp(x/b))-c)
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:
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.)
loglog(x(k),y(k),'-o')
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])
fittedmdl =
General model: fittedmdl(x) = a + b*(exp(max(x,0)/c)-1) Coefficients (with 95% confidence bounds): a = -0.02646 (-0.04634, -0.006587) b = 0.8506 (0.778, 0.9231) c = 1.332 (1.281, 1.383)
plot(fittedmdl,x,y)
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])
fittedmdl2 =
General model: fittedmdl2(x) = a + b*(exp(max(x,d)/c)-1) Coefficients (with 95% confidence bounds): a = -0.3442 (-0.3633, -0.3252) b = 1.436 (1.386, 1.486) c = 1.658 (1.631, 1.685) d = 0.3564 (0.3429, 0.37)
plot(fittedmdl2,x,y)
grid on
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])
fittedmdl3 =
General model: fittedmdl3(x) = a + b*max(x,0).^c Coefficients (with 95% confidence bounds): a = -0.0007654 (-0.007398, 0.005867) b = 0.7879 (0.7766, 0.7991) c = 1.958 (1.943, 1.974)
plot(fittedmdl3,x,y)
grid on
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)
hold on
plot(x,fittedmdl2(x) - y)
plot(x,fittedmdl3(x) - y)
grid on
legend('mdl','mdl2','mdl3')
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
federico 2023 年 8 月 31 日
the thing that bugs me out is the fit model3 "a + b*max(x,0).^c" as it should represent the equation model the fit is based on, if i understood the code.
if so, this should recall a math equation that i don't seem to recognise.
i beg your pardon but my coding experience started only recently and i'm trying to learn as best as i can, this is still new to me.

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by