2011-02-25 78 views
2

MatLab中的散點圖。我可以創建x和y陣列是相同的大小,如下散點圖:MatLab:散點圖和柵格圖

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似乎沒有這樣的功能?

任何幫助將是偉大的:)。

+0

我最終做的就是使用'hold on'和覆蓋圖工作正常。 pccofre的答案似乎也是正確的。 – ale 2011-02-26 14:47:35

回答

3

情節允許diferent大小矢量

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你有多個點上面的例子。