Matlab 关于比较3个变量和绘图的建议

Matlab 关于比较3个变量和绘图的建议,matlab,plot,Matlab,Plot,在下面的示例中,我希望您能提供一些关于绘制所需结果的最佳方法的反馈 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.96

在下面的示例中,我希望您能提供一些关于绘制所需结果的最佳方法的反馈

    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),例如

然而,我想绘制一幅图,显示随着水深的增加,一致性水平较高的位置是停留时间差异较小的位置


如有任何建议,将不胜感激

曲面图怎么样

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 i] = sort(depths);
correlations = correlations(:, i);
但这使得表面看起来很奇怪(因为深度16.78似乎比深度24的相关性低)

替换
[X Y]=meshgrid(深度、住宅)
[xy]=meshgrid(1:numel(深度),住宅)可能是有意义的(否则,深度=6.8和深度=16.3之间会有很大的差距)

您还可以尝试删除
着色interp
并将
surf(X,Y,correlations)
替换为以下内容

scatter3(X(:), Y(:), correlations(:), '.');
而是得到散点图

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