How to coding and plotting

1 回表示 (過去 30 日間)
dab483
dab483 2014 年 2 月 26 日
コメント済み: dab483 2014 年 2 月 26 日
Hi i have this Page hinkley test
sumPH=0
for t=1:Nt
mew2=(inv(Nt)*sum((y2-xhat2)));
vari2=(inv(Nt-1)*sum((xhat2-mew2).^(2)));
sumPH= sumPH + vv/vari2*(rg12 - mean(mew2) -vv/2);
pp=max(0,sumPH);
end
Now i want to plot (t,pp) using either 1 or zero. How do i coding if i want to make maximum of pp become 1 instead its own value of sumPH ?

採用された回答

Mischa Kim
Mischa Kim 2014 年 2 月 26 日
編集済み: Mischa Kim 2014 年 2 月 26 日
You mean normalize the plot?
sumPH=0
for t=1:Nt
mew2 = (inv(Nt)*sum((y2-xhat2)));
vari2 = (inv(Nt-1)*sum((xhat2-mew2).^(2)));
sumPH = sumPH + vv/vari2*(rg12 - mean(mew2) -vv/2);
pp(t) = max(0,sumPH); % save each data point
end
plot(t,pp/max(pp)) % plot normalized data
If you want to plot only 1s and 0s, then you would use
pp(t) = sumPH>0; % save each data point
...
plot(t,pp) % plot data
  3 件のコメント
Mischa Kim
Mischa Kim 2014 年 2 月 26 日
編集済み: Mischa Kim 2014 年 2 月 26 日
Yep, as outlined above, use
sumPH=0
for t=1:Nt
mew2 = (inv(Nt)*sum((y2-xhat2)));
vari2 = (inv(Nt-1)*sum((xhat2-mew2).^(2)));
sumPH = sumPH + vv/vari2*(rg12 - mean(mew2) -vv/2);
pp(t) = sumPH>0; % save each data point
end
plot(t,pp,'*') % plot data
...and make sure that t and pp are both row or both column vectors. Note, with '*' parameter the data points are plotted individually using a star as the marker symbol.
dab483
dab483 2014 年 2 月 26 日
ok. i think i got it! thanks for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDetection, Range and Doppler Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by