MatLab:分散图和光栅图

时间:2011-02-25 12:40:36

标签: matlab

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值怎么办?即数组大小不同。我认为这实际上被称为光栅图,但MatLab似乎没有这样做的事情?

任何帮助都会很棒:)。

2 个答案:

答案 0 :(得分:3)

绘图允许不同大小的向量

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

答案 1 :(得分:2)

当数组大小不同时,如何将每个y值映射到相应的x值?这很暧昧。

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

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

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

相关问题