Controlchart function with the conditional variance?

조회 수: 1 (최근 30일)
Karim Hasouna
Karim Hasouna 2020년 9월 12일
답변: Ayush Gupta 2020년 9월 17일
I am making a time series with the conditional variance and I want to create a plot.
This is my right code.
%% Model chart
v1 = sqrt(sigma2_hat)
ont = ones(1418);
on =fri(1:1418,1);
UCP = on*(1.96)
LCP = on*(-1.96)
qv1 = UCP.*v1
qv2 =LCP.*v1
dates =1:1418;
figure;
subplot(1,1,1)
h1 = plot(dates,y1,'Color','k')
hold on
h2 = plot(dates,qv1,'r--','LineWidth',2)
hold on
h3 = plot(dates,qv2,'r--','LineWidth',2)
title('Conditional Variances');
ylabel('Cond. var.');
xlabel('Period');
%
Then, I want to determine the values that are out on the Upper and lower limits (red line).
I did this
se =v1
st = controlchart(y1,'charttype','i','nsigma',2,'sigma',v1)
If I use a constant v1 (variance) works but I have a matrix and also my time series is a matrix with the same length.
Then, I should know how many points go beyond limits and create a legend.
Thanks.

답변 (1개)

Ayush Gupta
Ayush Gupta 2020년 9월 17일
The problem that is arising here is because of the fact the argument given to sigma that is v1 is, it can’t take multiple output. So, a matrix or an array argument to sigma should not be given. A possible workaround here could be to use a for loop and give value of v1 at each iteration. Refer to the following code for the workaround
for i=1:length(v1)
st = controlchart(y1,'charttype','i','nsigma',2,'sigma',v(1))
end

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by