ANOVA in matlab (MATLAB)

######################################################################################################

This script loads existing text files holding data and runs an anova of N size on them.

######################################################################################################

%Runs ANOVAs on the output from featquery. Takes shellscript output.

%Need to put the file/ROI name in filea.

#Name of output file from featquery

%filea=’1a_vlpfc_L’;

%filea=’1b_vlpfc_R’;

%filea=’2a_sma_L’;

%filea=’2b_sma_R’;

%filea=’3a_par_L’;

%filea=’3b_par_R’;

clear

#Group 1 is A, 2 is B.

fileA = [filea ‘.1.txt’];

fileB = [filea ‘.2.txt’];

#Now name all the files that you will import…

fileA2 = [‘cope6/’ fileA];

#… then load and name them.

group1_UR=load (fileA2);

fileA3 = [‘cope7/’ fileA];

group1_US=load (fileA3);

fileA4 = [‘cope8/’ fileA];

group1_BR=load (fileA4);

fileA5 = [‘cope9/’ fileA];

group1_BS=load (fileA5);

fileB2 = [‘cope6/’ fileB];

group2_UR=load (fileB2);

fileB3 = [‘cope7/’ fileB];

group2_US=load (fileB3);

fileB4 = [‘cope8/’ fileB];

group2_BR=load (fileB4);

fileB5 = [‘cope9/’ fileB];

group2_BS=load (fileB5);

#Set up vectors telling matlab which output each of the data points is

%Factor 1: group.

C_M ={ ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘C’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’; ‘M’ };

%Factor 2: Rule type (uni/bivariate)

U_B ={ ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘U’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’; ‘B’ };

%Factor 3: Switch or repetition.

R_S ={ ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘R’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’; ‘S’ };

Y =[ group1_UR; group1_US; group1_BR; group1_BS; group2_UR; group2_US; group2_BR; group2_BS ];

#Run the anova.

p = anovan(Y,{C_M U_B R_S},’model’,’full’)

Leave a comment