plotting matrices in scatter form

Hello
I was wondering if there is a way to get a scatter plot by just plugging in the matrix as opposed to
scatter(x,y,z) %Assuming the matrix has three columns
The columns of the matrix still represents the values for each axis, but I do not want to have to index like this: x=Matrix(:,1) y =Matrix(:,2) z=Matrix(:,3)
Is there a command like the following: somecommand(Matrix) and I get the same results?
Thank You

2 件のコメント

madhan ravi
madhan ravi 2019 年 4 月 7 日
but I do not want to have to index like this: x=Matrix(1,:) y =Matrix(2,:) z=Matrix(3,:)
?
sebastian pena
sebastian pena 2019 年 4 月 7 日
I am sorry I meant x=Matrix(:,1), etc

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

回答 (1 件)

David Wilson
David Wilson 2019 年 4 月 8 日

0 投票

Not easily, but the disperse function from the user's group (see https://au.mathworks.com/matlabcentral/fileexchange/33866-disperse) helps in these situations.
[x,y,z] = disperse(Matrix);
scatter(x,y,z)

3 件のコメント

sebastian pena
sebastian pena 2019 年 4 月 8 日
編集済み: sebastian pena 2019 年 4 月 8 日
Thank you for the response. But if I was doing a function that creates a matrix that varies in number of columns depending on the input to the function, how would one write a command that performs a scatter plot using all the columns of the matrix
Walter Roberson
Walter Roberson 2019 年 4 月 8 日
If you had a matrix with more than 3 columns, then what should be used for the X axis and what should be used for the Y axes and what should be used for the Z axes ? For example, if the matrix had 5 columns, then what would the equivalent scatter() commands be ?
sebastian pena
sebastian pena 2019 年 4 月 10 日
I suppose one constraint is that the max number of columns the matrix can have is 3 columns in the order of x y z. And if thats the case I'd think that if statements could be used. But I still wonder if there is a more elegant way. Thank you

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

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

質問済み:

2019 年 4 月 7 日

コメント済み:

2019 年 4 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by