【问题标题】:MatLab: Scatter Plots and Raster PlotsMatLab:散点图和光栅图
【发布时间】:2011-02-25 12:40:36
【问题描述】:

MatLab 中的散点图。我可以创建一个 x 和 y 数组大小相同的散点图,如下所示:

function RasterTest()

    clear all % clear memory
    clc; % clear command window
    close all; % close any figure windows that are open

    x=[1 2 3]; % x positions of the charges
    y=[4 8 2]; % y positions of the charges

    scatter(x,y,'filled')
    axis square

end

但是,如果我希望每个 x 都有多个 y 值怎么办? IE。数组大小不同。我认为这实际上被称为光栅图,但 MatLab 似乎没有这样做的东西?

任何帮助都会很棒:)。

【问题讨论】:

  • 我最终做的是使用hold on 并覆盖工作正常的图表。 pccofre 的答案似乎也是正确的。

标签: matlab


【解决方案1】:

绘图允许不同大小的向量

plot(x,[sin(x);2*sin(x);3*sin(x)],'*')

【讨论】:

    【解决方案2】:

    当数组大小不同时,如何将每个 y 值映射到相应的 x 值?这是模棱两可的。

    生成数据时,只需确保将每对值插入 x 和 y 数组即可:

    x = [1 2 3 1 3];
    y = [3 4 5 6 7];
    

    在上面的示例中,x 值 13 获得了多个点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-10
      • 2015-08-27
      • 2013-08-17
      • 1970-01-01
      • 1970-01-01
      • 2013-08-31
      • 2013-02-12
      • 2013-12-17
      相关资源
      最近更新 更多