How I got a and b value from cftool in MATLAB
조회 수: 2 (최근 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!