Reinderien
Reinderien

Reputation: 15243

Repeating x and y vectors for use with scatter3()

Currently I have a working 3D mesh() plot. However, the vertical axis lends itself better to an angular representation, so I'm constructing a coordinate transform to cylindrical space, after which I'll plot everything with scatter3().

Currently I have one-dimensional vectors containing all of the possible x and y values; however, they do not repeat (and they need to, to work in scatter3()). I have to flatten my two-dimensional z-matrix using z(:). Is there a quick method to repeat x and y to also be scatter3-compatible?

Thanks...

Upvotes: 0

Views: 136

Answers (1)

nibot
nibot

Reputation: 14928

Use meshgrid and then flatten:

[X,Y] = meshgrid(x,y);
scatter3(X(:), Y(:), z(:));

Upvotes: 1

Related Questions