How can I remove the error " Not enough input arguments" of nlinfit?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everybody. This is my code:
clc;clear;close all;
x=0:.1:2*pi;
y=sin(x);
pp=spline(x,y);
k=4;
t=x;
xq=x;
for i=1:length(y)-1
cc(:,i)=pp.coefs(i,1).*(x-pp.breaks(i)).^(k-1) + pp.coefs(i,2).*(x-pp.breaks(i)).^(k-2) +...
pp.coefs(i,k-1).*(x-pp.breaks(i)) + pp.coefs(i,k);
end
for i=1:length(y)-1
modelfun = @(x,a,b,c,d)(a(i).*(x-1)).^(k-1) + b(i).*(x-1).^(k-2) +c(i).*(x-1)+d(i);
rng('default') % For reproducibility
a(i)=pp.coefs(i,1);
b(i)=pp.coefs(i,2);
c(i)=pp.coefs(i,3);
d(i)=pp.coefs(i,4);
a0(i)=a(i);
b0(i)=b(i);
c0(i)=c(i);
d0(i)=d(i);
x = exprnd(2,63,1)';
z(i,:) = modelfun(x,a(i),b(i),c(i),d(i));
beta0(i,:)=[a0(i),b0(i),c0(i),d0(i)];
opts = statset('nlinfit');
opts.RobustWgtFun = 'bisquare';
beta(i)=nlinfit(x,z(i,:),modelfun,beta0(i,:),opts)
ci(i) = bootci(1000,{beta(i),x,z(i,:)},'Type','norm')
end
0 comentarios
Respuestas (1)
KSSV
el 15 de Nov. de 2021
Replace your modelfunction with:
modelfun = @(x,b)(b(1)*(x-1)).^(k-1) + b(2)*(x-1).^(k-2)+b(3)*(x-1)+b(4);
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!