2012-04-19 20 views
0

在下面的例子中,我希望获得关于绘制所需结果的最佳方法的一些反馈。比较3个变量和绘图的建议

clear all 
Table1 = {0.990,0.987,0.972,0.832,0.776,20;0.988,0.986,0.961,0.946,0.906,... 
    30;0.963,0.956,0.850,0.897,0.908,70;0.970,0.968,0.922,0.835,0.674,... 
    90;0.957,0.950,0.908,0.925,0.955,100;0.966,0.963,0.948784273781552,0.892,... 
    0.812,120;0.977,0.973,0.932,0.779,0.648,450;0.985,0.985,0.915,... 
    0.832,0.792,480;0.979,0.969,0.939,0.814,0.642,550;0.983,0.980,0.916,... 
    0.719,0.520,570;}; 
locations = {'loc1','loc2','loc3','loc4','loc5'}; 
CombLocation = locations(nchoosek(1:length(locations),2)); 
Table2 = [CombLocation,Table1]; 
Headings = {'location1','location2','depth1','depth2','depth3','depth4',... 
    'depth5','residence time'}; 
Table3 = [Headings;Table2]; 
depths = [5.3,6.8,16.3,24,16.78]; 

在这里,我们具有根据“停留时间”“表3”这表明了相关值(水温)的不同位置之间(“LOC1”,“LOC2”)被评为(其中停留时间是在各地点之间停留时间的差异)。我想要做的是表明随着深度的增加,一致性水平受停留时间的影响很大。

这可以针对每个深度单独完成,例如,

figure; 
plot(cell2mat(Table3(2:11,8)),cell2mat(Table3(2:11,7))); 

因此显示出,随着滞留时间的增加,相关性减小。然后可以重复较浅的深度,即深度(1),例如

figure; 
plot(cell2mat(Table3(2:11,8)),cell2mat(Table3(2:11,3))); 

不过,我想产生一个曲线图,表明,随着水深增加,一致性更高层次的位置是那些曾在停留时间差异较小。

任何意见,将不胜感激。

回答

1

表面图怎么样?

residences = cell2mat(Table3(2:end, end)); 
correlations = cell2mat(Table3(2:end, 3:end-1)); 
[X Y] = meshgrid(depths, residences); 
surf(X, Y, correlations) 
xlabel('Depth'); 
ylabel('Residence'); 
zlabel('Correlation'); 
shading interp; 

这应该表现出你想要的东西,但因为它是没有排序,这使得表面削减自身的下面你depths阵列看起来很奇怪。你可以如此修正:

[depths i] = sort(depths); 
correlations = correlations(:, i); 

但是这使得表面看起来很奇怪(自16.78的深度似乎比24深度较低的相关性)。

更换[X Y] = meshgrid(depths, residences);[X Y] = meshgrid(1:numel(depths), residences);可能是有意义的,如果你只是想表明会发生什么深度的增加(否则我们得到深度= 6.8和深度= 16.3差距较大)。

您也可以尝试用去除shading interp和东西代替surf(X, Y, correlations)

scatter3(X(:), Y(:), correlations(:), '.'); 

得到散点图来代替。