Title: Creating a cylinder with axis centered differently
Tags: matlab;geometry
Question: I know Matlab has a function called cylinder to create the points for a cylinder when number of points along the circumference, and the radius length. What if I don't want a unit cylinder, and also don't want it to center at the default axis (for example along z-axis)? What would be the easiest approach to create such a cylinder? Thanks in advance.

Here is the accepted answer: The previous answer is fine, but you can get matlab to do more of the work for you (because the results of cylinder separate x,y,z components you need to work a little to do the matrix multiplication for the rotation).  To have the center of base of the cylinder at [x0 y0 z0], scaled by [xf yf xf] (use xf=yf unless you want an elliptic cylinder), use:
[x y z] = cylinder;
h=mesh(x*xf+x0,y*yf+y0,z*zf+z0)
If you also want to rotate it so it isn't aligned along the z-axis, use rotate. For example, to rotate about the x-axis by 90 degrees, so it's aligned along the y-axis, use:
rotate(h,[1 0 0],90)
Comment for this answer: One more note. How do I retrieve the points from h once I created the mesh and rotate using the Matlab functions?
Comment for this answer: I found a general use function posted on file exchange that is friendlier, and a wrote up an answer for it: http://stackoverflow.com/a/32102395/999943  http://www.mathworks.com/matlabcentral/fileexchange/21951-cone/content//Cone.m
Comment for this answer: @stanigator: `get(h,'XData')`, `get(h,'YData')` and `get(h,'ZData')`. These are in the same form (default `2 x 21`) as the results of `cylinder`.

Here is another answer: Multiply the points by your favourite combination of a scaling matrix, a translation matrix, and a rotation matrix.
Comment for this answer: Thanks. That's actually what I somewhat did, although could be done more elegantly using the matrices as mentioned.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:03/10/10', 'FavoriteCount': 3.0, 'PostTypeId': 1, 'Tags': '<matlab><geometry>', 'Title': 'Creating a cylinder with axis centered differently', 'ViewCount': 11692, 'id': 2421557, 'user_AboutMe': '', 'user_AccountId': 34765.0, 'user_DisplayName': 'stanigator', 'user_Reputation': 10578.0, 'user_Views': 1879.0, 'user_id': 98299.0}}