I am having trouble with errors in the array used for anova analysis

17 次查看(过去 30 天)
Sorry for the messy code, but I've programmed a 10x3x3 anova analysis and I'm getting an error code and I don't know what's causing it.
Error Code : The grouping variable must be a categorical vector, numeric vector, logical vector, datetime vector, duration vector, character array, string array, or cell vector of character vectors.
The grouping variable must be a categorical vector, numeric vector, logical vector, datetime vector, duration vector, character array, string array, or character vector cell vector.
Does anyone know the cause?
dataFileName1 = 'AllParmeter_Exp1';
dataFileID1 = fopen([dataFileName1,'.txt'],'r');
if (dataFileID1 == -1);
error('data file not exist');
end
formatSpec = '%f';
y = fscanf(dataFileID1,formatSpec)
fclose(dataFileID1);
g1 = {1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10};
g2 = {'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW'};
g3 = {'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'CA';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'JP';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW';'TW'};
p = anovan(y,{g1,g2,g3})

采纳的回答

Jeff Miller
Jeff Miller 2022-11-22
Looks like g1 should be a numerical vector, not a cell array (i.e., square brackets instead of curly brackets). e.g.,
g1 = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10 et cetera];

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by