Skip to content

Cookbook: design matrix

AaronSeitz edited this page May 26, 2013 · 2 revisions
%% Example 3 - Make Design Matrix
% % written for Psychtoolbox 3  by Aaron Seitz 1/2012
%These lines create and randomize the design matrix
%This is a complicated what of doing so, but provides a framework 
%for making arbitrarily complex design matrices.

trpercond=20;
dl=5; % number of coherence levels
sl= 3; %sound-types 1-oldsound; 2-singlenew; 3-multinew;
dirs=2; %number of directions
congr=2; % congruent vs incongruent
%%%%% coherence, soundtype Vdirection Adirection interval
trmat=[repmat(1:dl,1,sl*dirs*congr*trpercond)'...
    repmat(ceil((1:(dl*sl))/dl),1, dirs*congr*trpercond)' ...
    repmat(ceil((1:(dirs*dl*sl))/(dl*sl)),1, congr*trpercond)' ...
    repmat(ceil((1:(dirs*dl*sl*congr))/(dirs*dl*sl)),1, trpercond)'....
    round(rand(dl*sl*dirs*congr*trpercond,1))];
mixtr = trmat(randperm(length(trmat)),:); %randomizes trial matrix
response=zeros(length(mixtr),2)-1; %intialize response matrix -1

Clone this wiki locally