I have a function saved as a 'calculateResults.m' in which the function 'ode45' is nested:
function y = calculateResults (concV, ksV, xTrace)
options = odeset('NonNegative', [1:size(concV,2)], 'RelTol', 1e-6, 'AbsTol', 1e-12);
[x,y] = ode45(@(t, cY)odeSet(t, cY, ksV), xTrace, concV, options);
I would like to use this function as a fittype:
ft = fittype('calculateResults( concV, ksV, x )','independent',{'x'});
But doing this causes the error:
Error using fittype/testCustomModelEvaluation (line 12) Expression calculateResults( concV, ksV, x ) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Error in fittype expression ==> calculateResults( concV, ksV, x ) ??? Index exceeds matrix dimensions.
My aim is to vary the values of 'concV' in order to fit the function 'calculateResults.m' to some data (x and y):
mdl = fit( x, y, ft);
And finally return the values of concV that best fit the data:
concVCalc = mdl.Coefficients.Estimate;
Please help! Thank you!
concV
andksV
. Looks likeconcV
is a "coefficient", andksV
is a "problem" variable? - Peter