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

17 views (last 30 days)
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})
  1 Comment
Image Analyst
Image Analyst on 22 Nov 2022
You forgot to attach ''AllParmeter_Exp1.txt';
If you have any more questions, then attach your data with the paperclip icon after you read this:

Sign in to comment.

Accepted Answer

Jeff Miller
Jeff Miller on 22 Nov 2022
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];

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!