Avoiding for loop with anova1
3 views (last 30 days)
Show older comments
I have 2 large 3D matrices, and I've noticed that passing a DIM argument for the ttest2 function decreases the computational time on my computer substantially as opposed to looping through each index in the first 2 dimensions (near 60-fold for the data I'm working with):
[~,~,~,stats]=ttest2(A,B,[],[],[],3);
vs.
stats=cell(rmax,cmax);
for r=1:rmax
for c=1:cmax
[~,~,~,stats{r,c}]=ttest2(A(r,c,:),B(r,c,:));
end
end
Now I would like to do the same thing, but adding another matrix C and using anova1 instead of ttest2. The documentation for anova1 suggests that it won't accept a similar DIM argument, but I'm wondering if there's a similar way to cut down on time and avoid looping through each element.
Thanks!
Zach
4 Comments
Star Strider
on 5 Apr 2015
I still have no idea what you’re doing, but if you’re doing clustering, you might want to look through the Statistics Toolbox for cluster algorithms such as clusterdata. There are several others, and several related functions, such as those listed at the end of that webpage.
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!