Mean of matrices in cell array
1 次查看(过去 30 天)
显示 更早的评论
I have a 100x40 cell array, each cell contains a 46x2 double, which is the score output from classifiers: knn, treebagger, svm. I am trying to make ROC curves from the scores, but I need to take the mean of the elements in each array. Basically, the 100 is the number of iterations for which I ran my code and the 40 is the number of feature sizes selected. The 46 is the number of test points I used. I need the mean of the score for each sample size. I am relatively new to MATLAB and am not sure where to start. I read through other posts and found some help, but cannot seem to apply it to my issue. The code I tried is:
catscore=mean(cat(2,scorepofknn15{:}),2);
which did not produce the desired result. Any help or suggestions would be greatly appreciated.
0 个评论
回答(1 个)
Sandra Preaux
2018-10-2
I'm not sure from your question if you are trying for catscores to be 100x40 or 1x40. So I'll show both. If you want 100x40 (one average for each run of each feature size) then use this loop
xm=zeros(size(scorepofknn));
for ii=1:size(scorepofknn15,1)
for jj=1:size(scorepofknn15,2)
xm(ii,jj)=mean(scorepofknn15{ii,jj});
end
end
If you want to cat all runs for the same feature size together use this loop
xm=zeros(1,size(scorepofknn15,2));
for ii=1:size(scorepofknn15,2)
xm(1,ii)=mean([x{:,ii}]);
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Classification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!