2012-04-19 18 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(:), '.'); 

得到散點圖來代替。