How I got a and b value from cftool in MATLAB
4 ビュー (過去 30 日間)
古いコメントを表示
How I got a and b value from cftool in MATLAB by this equation
y=ln[q*tsi*ltw*a]-exp(b/x), where rest of the parameter values are
q=1.6*10^-19
tsi=10*10^-9
ltw=0.04583
x=[1.91E-05 1.36E-05 1.11E-05 9.62E-06 8.62E-06 7.87E-06 7.30E-06 6.80E-06 6.41E-06];
y=-[86.00 78.00 74.00 72.00 71.00 70.00 69.00 68.00 67.00];
please help me to find out a and b
0 件のコメント
回答 (1 件)
Abhaya
2024 年 10 月 9 日
編集済み: Abhaya
2024 年 10 月 9 日
Hi Jayabrata,
I understand you're trying to determine the coefficients 'a' and 'b' from a custom equation using MATLAB's curve fitting tool.
While reproducing the code at my end I see that the error encountered is “inf computed by model function fitting can not continue”. The error is because during the fitting process, some computations are resulting in infinite(Inf) or undefined values(NaN).
You can use ‘lsqcurvefit’ function of MATLAB to handle lower and upper bound errors for 'a' and 'b'. You can use “max(c(1),eps)” to ensure that the value inside the logarithm “q*tsi*ltw*a” is positive always.
Please refer to the modified code for better understanding:
q = 1.6e-19;
tsi = 10e-9;
ltw = 0.04583;
model = @(c, x) log(q * tsi * ltw * max(c(1), eps)) - exp(c(2) ./ x);
% Initial guesses for a and b (make sure the initial guess for 'a' is reasonable)
initial_guess = [1e10, 0];
% Define the lower and upper bounds for a and b (a must be positive)
lb = [0, -10]; % Lower bound for 'a' (positive) and 'b'
ub = [100, 100]; % Upper bound for 'a' and 'b'
% Data
x = [1.91E-05 1.36E-05 1.11E-05 9.62E-06 8.62E-06 7.87E-06 7.30E-06 6.80E-06 6.41E-06];
y = -[86.00 78.00 74.00 72.00 71.00 70.00 69.00 68.00 67.00];
% Perform the curve fitting using lsqcurvefit
options = optimset('Display','off');
[c, resnorm] = lsqcurvefit(model, initial_guess, x, y, lb, ub, options);
% Display the results
a = c(1);
b = c(2);
disp(['Fitted value of a: ', num2str(a)]);
disp(['Fitted value of b: ', num2str(b)]);
For more information, please follow the MATLAB documentations given below.
Hope this solves your query.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!