boxplot of correlation values from a cell array

1 view (last 30 days)
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?

Accepted Answer

the cyclist
the cyclist on 10 Mar 2012
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.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!