matlab - Rotating a Plot About the Y Axis -
i have vector of values want plot brightness on circle through radius of (i.e. if 0 3 1 5 i'd want circle dark @ centre, bright ring around it, darker ring, brighter ring).
to i've attempted rotate radial vector (e) around y axis, such
[x,y,z] = cylinder(e); h = surf(x,y,z),
however i'm not doing right, appears rotating curve around x axis. i've tried swapping x , y, still rotates around x axis. appreciated.
one way rotate vector , create surface
. z data of surface (your rotated vector) color coded according colormap choose, if display surface top circles @ different brightness.
if interested "top view" of surface, no need create full surface, simple pcolor
job.
example:
%% // input data (and assumptions) e=[0 3 1 5 2 7]; nbrightness = 10 ; %// number of brightness levels r = (0:numel(e)) ; %// radius step=1 default consecutive circles %// otherwise define different thickness each circle
so if use stairs([e 0])
different brightness levels:
i had add last 0
vector "close" last level, we'll have again in solution below.
now rotate/replicate around y, color code height, , @ top:
%% // replicate profile around axis ntt = 50 ; %// define how many angular division plot theta = linspace(0,2*pi,ntt) ; %// create angular divisions [rr,tt]=meshgrid(r,theta) ; %// generate grid z = repmat( [e 0] , ntt , 1 ) ; %// replicate our "e" vector match grid [xx,yy,zz] = pol2cart(tt,rr,z) ; %// convert cartesian coordinates pcolor(xx,yy,zz) %// plot colormap(gray(nbrightness)) %// make sure use "nbrightness" colors (shades of gray) caxis([0 nbrightness]) shading flat ; axis equal %// refine view (axis ratio , "spokes" not visible) etc... colorbar axis off
will yield following :
note problem not defined, had take assumptions on:
- what radius each brightness circle should have ? (i made them same can modify that)
- how many brightness levels want ? (you can modify though).
Comments
Post a Comment