Create design matrix for ANOVA

1 回表示 (過去 30 日間)
Jihyeon Kim
Jihyeon Kim 2017 年 4 月 22 日
回答済み: Prashant Arora 2017 年 4 月 27 日
How can I create a design matrix for ANOVA test manually without writing 0's and 1's (too tedious!!) ? Such as [1 1 0 0; 1 1 0 0; 1 0 1 0; 1 0 1 0; 1 0 0 1; 1 0 0 1]
Thanks in advance!

回答 (1 件)

Prashant Arora
Prashant Arora 2017 年 4 月 27 日
You can start with zeros and use matrix indexing to create ones.
A = zeros(10);
rowInd = [1 2 3 4];
colInd = [5 7 8 9];
Ind = sub2ind(size(A),rowInd,colInd);
A(Ind) = 1;
If there's some pattern involved, you can probably do this more efficiently.

カテゴリ

Help Center および File ExchangeANOVA についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by