Zscore array subset
5 ビュー (過去 30 日間)
古いコメントを表示
I am calculating a simple zscore, across my rows for a matrix. What I want to return, in ONE line of code, is just the last column of zscores. In other wordse I am using the code below where I would like a zscore for today, based off a trailing 252 day period. What I get with the function to the right of the equals sign is the full matrix of zscores of Nrows X 252 columns.
c=252;
SP_Zscores(:,c) = zscore(SP_MovAvg(:,c-251:c),1,2);
Thanks for the help, Brian
0 件のコメント
採用された回答
Oleg Komarov
2012 年 4 月 4 日
"Z = zscore(X) returns a centered, scaled version of X, the same size as X"
Doing it manually:
(SP_MovAvg(:,c) - mean(SP_MovAvg(:,c-251:c),2))./std(SP_MovAvg(:,c-251:c),1,2)
2 件のコメント
Oleg Komarov
2012 年 4 月 4 日
The last column only is normalized, i.e. SP_MovAvg(:,c).
The ./ is the elementwise division (see the help for details).
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!