boxplot of correlation values from a cell array
조회 수: 1 (최근 30일)
이전 댓글 표시
Before describing my question I provided the following code, which help me in describing what I'm trying to do:
clear all
AirT = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
SolRad = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
Rain = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
Location = {'England','Wales','Scotland','Ireland'};
points = {1,2,2,2};
CorrVariables = {'AirT','SolRad','Rain'};
for i = 1:length(Location);
Data = @(location) struct('Location',location,CorrVariables{1},AirT{i},...
CorrVariables{2},SolRad{i},CorrVariables{3},Rain{i});
D(i) = Data(Location{i});
end
FieldName = {D.Location};
R = corrcoef([D.AirT],'rows','pairwise');
R_Value = [Location(nchoosek(1:size(R,1),2)) num2cell(nonzeros(tril(R,-1)))];
q = points(nchoosek(1:size(R,1),2));
%to calculate the combination of these points we need to convert the
%cell into a matrix.
qq = cell2mat(q);
%calculate
qq = qq(:,1)+qq(:,2);
%insert into R_Values in the last row.
Re = [R_Value num2cell(qq)];
The code above is not really important but the output provides a better explanation than what I can give.
So, in 'Re' we have the name of the pairs (Re(:,1:2)) of data used in calculating the correlation coefficient (Re(:,3)) and then the combination of the points assigned to each pair (Re(:,4)).
From this I hope to produce a boxplot which shows the correlation values of those pairs with points = 3 in one box and another box showing the correlation values of the pairs with points = 4.
How would I go about doing this?
댓글 수: 0
채택된 답변
the cyclist
2012년 3월 10일
boxplot(cell2mat(Re(:,3)),Re(:,4))
This first input argument is the data, and the second input argument is the "grouping variable" that indicates the data categories.
See
doc boxplot
for details.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!