How to I limit the plot range to [0, 4]?

Answers (1)

Star Strider
Star Strider on 29 Nov 2018
Use the axis (link) function.

5 Comments

Does not help when I cannot get linespace to work, but thanks.
You posted no code, so I have no idea what the problem may be with linspace.
If you want ‘x’ for example to go from 0 to 4 with 150 points, the linspace call would be:
x = linspace(0, 4, 150);
I've been tryingto get a similar image like in the picture I posted.
Here is my code:
[x,y,z] = cylinder(3);
z(2, :) = 4;
surf(x,y,z);
x = linspace(0, 4, 150);
y = linspace(0, 4, 150);
z = linspace(0, 4, 150);
However, the figure is still from [-4, 4] for the x and y axis. I am trying to restrict all axis on my plot from [0, 4]
I got it to work with xlim, linspace did not work for some reason. Thank you for your help though.
The linspace function will create vectors. It will not do anything with respect to the axis limits.
I would do something like this (using the axis function, as I previously described):
[x,y,z] = cylinder(3);
z(2, :) = 4;
surf(x,y,z);
axis([0 4 0 4 0 4])

Sign in to comment.

Categories

Find more on Graphics Objects in Help Center and File Exchange

Asked:

on 29 Nov 2018

Commented:

on 29 Nov 2018

Community Treasure Hunt

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

Start Hunting!