フィルターのクリア

How to give diferent colours to diferent values in a matrix?

1 回表示 (過去 30 日間)
Inês Rodrigues
Inês Rodrigues 2016 年 10 月 26 日
コメント済み: Adam 2016 年 10 月 26 日
Hi! I have a 3d matrix of 0's and 1's. I would like to plot it with scatter3 with 0's showing up black and 1's showing up white. Is that possible?
Thank you, Inês

採用された回答

Adam
Adam 2016 年 10 月 26 日
編集済み: Adam 2016 年 10 月 26 日
scatter3(X,Y,Z,S,C)
The final argument there is a colour vector, of equal length to the X and Y vectors. If you don't care about the marker type you can pass in [] as the S argument.
  4 件のコメント
Inês Rodrigues
Inês Rodrigues 2016 年 10 月 26 日
I'm really sorry but I'm not understading. I have a 3d matrix with different values. I thresholded it in order to be only 0 and 1, like a mask. And now I want to visualize the result. So I want to have a 3d scatter plot with all my points, with 0's in black and 1's in white.
Adam
Adam 2016 年 10 月 26 日
So in that case you will have to create the X, Y and Z values first. The X, Y and Z vectors that scatter3 takes as its arguments represent the points that it will plot, so you need to create these vectors in such a way that they include every (x,y,z) triplet. You should be able to do this using
doc meshgrid
but a scatter plot doesn't really seem like a suitable way of displaying such regular data filling a grid. It is unlikely you will be able to interpret much off it.

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

その他の回答 (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