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 CenterFile Exchange에서 ANOVA에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by