Fit model to measured data without toolbox
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
nlinfit () in the stat toolboox is likely to what I want but I do not have the stat toolbox (nor do I have the optimization toolbox). I need to fit my model to measured data and extract model parameters. My model function ( myModel.m) is of the form
function Pout = myModel (pVector, Lvector, G, H)
k = 1;
for L = Lvector
P = AnotherFunction (pVector, L, G, H)
Pout(k) = P;
k=k+1;
end
where, pVector = [a, b, c, d, ...]'; contains the model parameters a, b, c, d...so on and L_vector is another vector of different length (= number of measured data points). G and H are constants for a given case (measurement). Pout is a vector of the same length as Lvector. I have tried the following using a cost function and fminsearch but throws an error which I am unable to resolve.
pGuess = [aGuess, bGuess, cGuesss, dGuess...]; % initial guess values for model paramters
G = SomeknownConstant; H = SomeknownConstant;
load MeasuredData.dat; mData = MeasuredData;
myCostFunc = @(pVector) sum ((myModel (pVector, Lvector, G, H) - mData).^2); % my COST function
opts = optimset('MaxFunEvals',40000, 'MaxIter',10000);
pVectorEstimated = fminsearch (myCostFunc,pGuess, opts);
This gives me an error when I use Lvector as a vector but runs when Lvector is single valued? Lvector needs to be a vector (with length equal to that of mData) as used in myModel.m in order to generate a model data close to the measured data, which then gets fitted to the measured data by varying the model parameters. Where am I going wrong? Are there alternatives to nlinfit e.g in fileexchange that I could use?
0 Commenti
Risposte (2)
Alan Weiss
il 24 Ott 2017
I suggest that you try evaluating myCostFunc(pGuess) and seeing if the result is a scalar.
If it is a scalar, then please provide the exact error message (copy-paste) for more help, as we cannot tell what is happening from the incomplete information you have provided.
Alan Weiss
MATLAB mathematical toolbox documentation
3 Commenti
Vedere anche
Categorie
Scopri di più su Surrogate Optimization in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!