Data fit problem, 'Data must be numeric, datetime, duration or an array convertible to double.'
Afficher commentaires plus anciens
Dear all. I am trying to fit my model to data and determine the confidence interval for the fitted parameters. However, when I run my code, I get an error 'Data must be numeric, datetime, duration or an array convertible to double'. I am sure the problem is that "fittedmdl" is an object. I have tried to search related questions online but still I can't seem to get round my problem. Any insight into this will greatly be appreciated. Below is my code.
close all; clear; clc;
x=[100; 101.0932476; 97.12643678; 97.51209399; 96.89011748; 74.54219031; 84.76551121; 58.28584719; 50.17251294; 51.58143659; 48.325];
t=[0; 24; 24; 24; 24; 48; 48; 48; 72; 72; 72;];
fo = fitoptions('Method','NonlinearLeastSquares',...
'Lower',[0,0,0,0],...
'Upper',[Inf,max(t)],...
'StartPoint',[20 0.1 0.1 0.1]);
fittedmdl = fittype('100*A*exp((-C.*(1-exp(-lambda.*t))/lambda)-(D*(exp(-lambda.*t)-1+lambda.*t)/lambda^2))', ...
'independent',{'t'},'coefficients',{ 'A', 'C', 'D', 'lambda'},'options',fo)
[curve2,gof2] = fit(t,x,fittedmdl)
H = plot(fittedmdl,t,x); H(1).MarkerSize = 20; H(1).Color = 'm'; H(2).Color='k';H(2).LineWidth=2;
hold on
xint = linspace(min(t),max(t),1000);
CIF = predint(fittedmdl,xint,0.95,'Functional'); % 95% CI for the fitted curve
plot(t,x,'.m', MarkerSize=20)
hold on
plot(xint,CIF,'-b',linewidth=1)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!