Matlab中的热图和轮廓图

埃格巴尔

假设我掌握了以下信息:第一列是电动机的特征之一,第二列是特征二的特征,第三列是响应(在这种情况下为电动机的性能)。

[34 56 100
12 12 80 
7 6 60
3 4 20
1 1 10.5
0 0 1]

我想有这样的事情heatmap或者contour是比如我有第一排的矩阵和更浅的颜色更暖(如红色)的两排等我应该怎么办?

谢谢。

贾斯汀·弗莱彻(Justin Fletcher)

您可以结合使用image(),标准颜色图和对数据进行巧妙的处理。尝试这个:

yourData = [34 56 100;
            12 12 80;
            7  6  60;
            3  4  20;
            1  1  10.5;
            0  0  1];

%// First, normalize each column relative to itself.
normData(:, 1) = yourData(:, 1)/max(max(yourData(:, 1));
normData(:, 2) = yourData(:, 2)/max(max(yourData(:, 2));
normData(:, 3) = yourData(:, 3)/max(max(yourData(:, 3));

%// Next, adjust each column to a particular location on the default colormap
%// Adjust the scale and constant offsets to preference. Lower offsets are cooler.
scale = 5;
scaledData(:, 1) = (scale*normData(:, 1)) + 58;
scaledData(:, 2) = (scale*normData(:, 2)) + 46;
scaledData(:, 3) = (scale*normData(:, 3)) + 20;

image(scaledData);

好玩的问题。请享用!

更新

我以为这是个整洁的问题,所以我把它变成了一个函数。看看这个:

function scaledData = colorcolumn(C, scale)
    for colNum = 1:size(C, 2)
        normData(:, colNum) = C(:, colNum)/max(max(C(:, colNum)));
        scaledData(:, colNum) = (scale*normData(:, colNum)) + colNum*(64/size(c,2));
    end
end

尝试以下效果:

image(colorcolumn(rand(50,25), 5);

欢迎提供效率反馈。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章