3

我有一组 m 矩阵形状的向量,我想从中计算叠加的 m 个范数图。这很简单:

c=rand(100,10);
figure
normplot(c)

normplot 会自动为每列数据着色,但我想控制它们的着色方式。具体来说,我需要使它们成为灰度。第一组数据(第 1 列)应为白色(或接近白色),最后一组数据为黑色。

4

1 回答 1

3

通过获取绘制线的句柄,您可以像这样:

close all;
n = 100;
m = 10;
doc=rand(n,m);
figure;

% obtain the handle h to the dotted lines
h = normplot(doc);

% define colormap
g = colormap('gray');

for i = 1:m
    %set(h([1 11 21]),'color','r') % to set color to red
    %set(h([1 11 21]),'marker','o') % to change marker

    % mapping into greyscale color map (g has size 64x3)
    set(h([i i+m i+2*m]),'color',g(round(i * size(g,1)/m),:));
end

在此处输入图像描述

于 2013-04-08T13:36:21.053 回答