How do I set coefficient variables in Fittype that was generated in Fitting toolbox?
Mostra commenti meno recenti
Hello.
I am trying to fitting some equations to my data and here I am using Fittype which was generated by Curve Fitting Application. The fitting function is below.
I am wondering how I can set coefficient on this equation.
For example, the current equation is
A1*exp(B1*-2.7)*exp(-1*Ea1/8.62e-5*(1/(273+105)))*log(1+C*x)+A2*exp(B2*-2.7)*exp(-Ea2/8.62e-5*(1/(273+105)))*x^n1
but I wanted to change this to
A1*exp(B1*V)*exp(-1*Ea1/8.62e-5*(1/(273+T)))*log(1+C*x)+A2*exp(B2*V)*exp(-Ea2/8.62e-5*(1/(273+T)))*x^n1
The values of V and T will be given in the script. V = [-1.8 -2.7 -3.0] and T = [30 70 105]
The fitting function as of now, if I wanted to run with different V (voltage), I need to generate another fitting function.
I would really appreciate if you provide any input to go through it. Thank you!
======================================================
function [fitresult, gof] = testfitstress(ts, y_Ts)
%% Fit: 'fitstress'.
[xData, yData] = prepareCurveData( ts, y_Ts );
% Set up fittype and options.
ft = fittype( 'A1*exp(B1*-2.7)*exp(-1*Ea1/8.62e-5*(1/(273+105)))*log(1+C*x)+A2*exp(B2*-2.7)*exp(-Ea2/8.62e-5*(1/(273+105)))*x^n1', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.538342435260057 0.996134716626885 0.106652770180584 0.86869470536351 0.0781755287531837 0.0844358455109103 0.399782649098896 0.259870402850654];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
======================================================
3 Commenti
dpb
il 29 Lug 2022
Well, if you fix some of the parameters, the result of fitting will be different -- not much way around that.
Only thing that comes to mind would be to pre-generate the fits and store the results in an array for use later.
Are there three possibilities (the V,T values for three indices of the arrays) or all combinations of the three values (9 cases)?
Note that expressions like this,
A1*exp(B1*V)*exp(-1*Ea1/8.62e-5*(1/(273+T)))
and,
A2*exp(B2*V)*exp(-Ea2/8.62e-5*(1/(273+T)))
do not involve the independent variable x and can take on any value by suitable selection of A1 and A2. They can therefore be replaced with single coefficients Q1 and Q2, simplifying the model to
y = Q1*log(1+C*x)+ Q2*x^n1
Not to do so gives you a highly over-parametrized problem.
Once you have fitted Q1 and Q2, you can explore valid values for the original parameters by considering the equations,
A1*exp(B1*V)*exp(-1*Ea1/8.62e-5*(1/(273+T))) = Q1
A2*exp(B2*V)*exp(-Ea2/8.62e-5*(1/(273+T))) = Q2
for different values of T and V. However, because this is a system of 2 equations in 6 unknowns, you should expect that many possible solutions exist.
Jasmine
il 30 Lug 2022
Risposta accettata
Più risposte (1)
Steven Lord
il 31 Lug 2022
0 voti
On the documentation page for the fittype function, see the "Use Anonymous Functions to Work with Problem Parameters and Workspace Variables" example that has a problem-dependent parameter c (which is not a coefficient to be fit) and how that problem-dependent parameter is assigned a value when the fit is performed.
1 Commento
Categorie
Scopri di più su Linear Predictive Coding in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!