Can anyone tell me what is the difference between scatter and plot commands in Matlab?

114 ビュー (過去 30 日間)
Geethika
Geethika 2013 年 6 月 26 日
移動済み: Dyuman Joshi 2024 年 3 月 1 日
Hi I am new to matlab and going through basics. I am trying to plot points in Matlab HOwever, plot(1,2,3,4)
and
scatter([1,3],[2,4])
give me the same results. So what is the difference between plot and scatter command?
  2 件のコメント
vthuongt
vthuongt 2015 年 11 月 17 日
移動済み: Dyuman Joshi 2024 年 3 月 1 日
Is there any difference in speed and memory usage?

サインインしてコメントする。

採用された回答

Hugo
Hugo 2013 年 6 月 26 日
scatter draws points without lines connecting them whereas plot may or may not plot the lines, depending on the arguments.
scatter returns a handle to an object called scattergroup whereas plot returns a handle to an object called lineseries. The scattergroup object has some properties (for example, for associating the size of the dots to a variable in the workspace) that are not present in the lineseries objects. Analogously, the lineseries has some properties (for exmaple, for controlling the type of lines) that are not present in the scattergroup object.
scatter allows you to specify a different colour and a different size for each point individually. It is not possible to do that with plot.
Hope this helps.
  2 件のコメント
Geethika
Geethika 2013 年 6 月 26 日
Hi Hugo, Thanks for the reply. Can you give me a code in scatter which enables me to specify different color and size for each point individually? Thanks
Hugo
Hugo 2013 年 6 月 28 日
編集済み: Hugo 2013 年 6 月 28 日
a=rand(100,3);
scatter(a(:,1),a(:,2),[40*ones(50,1);5*ones(50,1)],a(:,3))
That gives you random points in two different sizes and with random colours.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by