在MATLAB中使用ciplot的置信带

时间:2018-04-11 21:09:55

标签: matlab

我正在尝试使用ciplot函数在MATLAB中绘制一个置信区域

代码如下:

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);

我收到以下错误

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);

请帮忙。

1 个答案:

答案 0 :(得分:1)

我猜ciplot是来自Mathworks' FileExchange的函数。在这种情况下,函数需要相同长度的矢量用于lower,upper和x。我认为这就是你要找的东西:

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)]);