首页 文章

在Matlab中绘制密度图

提问于
浏览
0

我想绘制一个情节

enter image description here

此图中的值1由白点显示,值0由黑点显示 . 它应该显示给定 xy 坐标作为输入的范数的结果值 . 这是与here中的文章类似的图表

如何在Matlab中绘制这种图形?是否按here中所述使用 Density 完成 .
但我不明白图表是如何绘制的?如果是 Matlab 命令可以有人请解释它的论据是什么?
如何绘制这种类型的 density 图形?

1 回答

  • 0

    有几种相关的方式可以显示您的要求 . 这里有几个:

    %define the value of r over a 2D grid:
    x_vec = linspace(0,1,600);
    [x,y] = meshgrid(x_vec,x_vec);
    r = (x.^2 + y.^2).^(1/2);
    %pixel coordinates begin at top left instead of bottom left, so flip the matrix:
    r = flipud(r);
    imshow(r);
    

    如果你更喜欢着色 not 填充网格,但是在 arbitrary 点指定,这将起作用:

    N = 3000;
    xvals = rand(1,400);
    yvals = rand(1,400);
    rvals = (xvals.^2 + yvals.^2).^(1/2);
    size  = 30;
    h = scatter(xvals,yvals,size,rvals,'filled');
    colormap gray
    

相关问题