How can I define a foor loop in which there is a bootci function?

1 view (last 30 days)
Hello. Firstly I estimate cubic splines coefficients and then I would like to implement bootstrap function on each interval of cubic splines. This is my code and I got the error " Not enough input arguments ".
t=0:.1:pi;
y=sin(t);
N=length(t); %number of points
n=N-1; %number of subintervals
h=(t(N)-t(1))/n; %step size
% h=2;
Trid=diag(4*ones(1,n-1))+diag(ones(1,n-2),1)+diag(ones(1,n-2),-1);
for i=1:n-1
z(i)=6/h^2*(y(i+2)-2*y(i+1)+y(i));
end
z=z';
w=inv(Trid)*z;
sigma=[0;w;0];
for i=1:n
d(i)=y(i);
b(i)=sigma(i)/2;
a(i)=(sigma(i+1)-sigma(i))/(6*h);
c(i)=(y(i+1)-y(i))/h-h/6*(2*sigma(i)+sigma(i+1));
end
r=1; %number of subintervals
hh=h/r; %step size of subintervals
x=t(1):hh:t(N);
for i=1:n
for j=r*(i-1)+1:r*i
s(j)=a(i)*(x(j)-t(i))^3+b(i)*(x(j)-t(i))^2+c(i)*(x(j)-t(i))+d(i);
end
end
s(r*n+1)=y(N);
for i=1:n
s_i{i}=@(x) a(i)*(x-t(i)).^3+b(i)*(x-t(i)).^2+c(i)*(x-t(i))+d(i);
end
k=1;
for i=1:n
B = [-.161 0 1 0];
beta0(i,:)=[a(i) b(i) c(i) d(i)];
x=t';
s_i{i}=@(x) a(i)*(x-t(i)).^3+b(i)*(x-t(i)).^2+c(i)*(x-t(i))+d(i);
modelfunc(i)=s_i{i};
beta(i) = @(predictor,response)nlinfit(predictor,response,modelfunc(i),beta0(i,:))
c(:,k) = bootci(1000,beta(i),t',y,'Type','norm');
k=k+2;
end

Accepted Answer

Alberto Cuadra Lara
Alberto Cuadra Lara on 30 Oct 2021
I have not checked all the code, but that error is because you are not declaring the inputs well. Use { } inside bottci function.
bootci(1000,{beta(i),t',y},'Type','norm');

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!