Statistic analysis on cell arrays
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I need to do check if the influence of two parameters on my data is significant. The data is organized in a cell array. Here is some code to generate test data:
MATLAB code
% Example data: random with offsets
%(Number of datapoints are different)
a1b1 = rand(42,1) + 0.5;
a2b1 = rand(25,1) + 1.0;
a3b1 = rand(32,1) + 1.2;
a1b2 = rand(37,1) + 0.8;
a2b2 = rand(23,1) + 1.2;
a3b2 = rand(29,1) + 1.3;
% Data is organized in a cell array
testData = {a1b1,a1b2;a2b1,a2b2;a3b1,a3b2};
testDataMean = cellfun(@mean,testData);
testDataStd = cellfun(@std,testData);
% Plot bar graph
hbar = bar(testDataMean);
Now, my question: How can I test if the influence of parameters A and B is significant?
I guess that the anovan function could possibly do what I need, but I can't get it to work on my cell array.
Can anyone help me with suggestions?
0 commentaires
Réponses (1)
Matt Tearle
le 10 Fév 2011
I think this is what you're looking for:
A = nominal([ones(42,1);2*ones(25,1);3*ones(32,1);...
ones(37,1);2*ones(23,1);3*ones(29,1)]);
B = nominal([ones(42+25+32,1);2*ones(37+23+29,1)]);
data = [a1b1;a2b1;a3b1;a1b2;a2b2;a3b2];
anovan(data,{A,B})
The idea is to stack everything into one long vector and create accompanying grouping variables (A & B). You don't need to make them nominal, but it's cool if you do :) I used values (A = 1,2,3, B = 1,2) just because that's how you labeled them, but you could use other labels instead. The repmat function is handy, in that case -- eg:
B = nominal([repmat('X',42+25+32,1);repmat('Y',37+23+29,1)]);
0 commentaires
Voir également
Catégories
En savoir plus sur Analysis of Variance and Covariance dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!