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

17 ビュー (過去 30 日間)
Kaminosono Shougo
Kaminosono Shougo 2022 年 11 月 22 日
コメント済み: Kaminosono Shougo 2022 年 11 月 24 日
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 件のコメント
Image Analyst
Image Analyst 2022 年 11 月 22 日
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:

サインインしてコメントする。

採用された回答

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 Center および File ExchangeAnalysis 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