Reputation: 189
I am trying to draw a confidence band in MATLAB using the ciplot function
The code as follows:
Y=Y(:,1); % 5139 by 1 vector
pd = fitdist(Y,'Normal');
ci = paramci(pd);% gives a 2 by 2 matrix of lower, upper for my(:,1) and sigma(:,2)
%ciplot(lower, upper,x, colour)
ciplot(ci(1,1),ci(2,1),Y);
I get the following error
Error using fill
Vectors must be the same length.
Error in ciplot (line 36)
fill([x fliplr(x)],[upper fliplr(lower)],colour)
Error in GHVDConfidenceInterval (line 12)
ciplot(lower,upper,Y);
Please help.
Upvotes: 1
Views: 620
Reputation: 1576
I guess ciplot
is the function from Mathworks' FileExchange. In this case, the function expects the same length of vectors for lower, upper and x. I think this is what you are looking for:
Y = randn(5139,1);
pd = fitdist(Y,'Normal');
ci = paramci(pd);
plot(Y);
hold on;
ciplot([ci(1,1) , ci(1,1)] , [ci(2,1) , ci(2,1)] , [1 length(Y)]);
Upvotes: 2