• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Matlab help please

WhiteKnight

Platinum Member
Does anyone know how to plot just a line between two points in 3d? My professor told us to use plot3, but plot3 requires 3 inputs (scalars or matrices) and then draws a line/lines to connect those three points. I just want to plot the line between two. I tried plotting plot3(a,b,a) (in an attempt to actually get the line between a and b, but that didn't work.
 
I looked at the help file for plot3 but I can't find any programs online that do what I am looking for. I don't have a book.
 
How about typing "help plot3":

PLOT3 Plot lines and points in 3-D space.
PLOT3() is a three-dimensional analogue of PLOT().

PLOT3(x,y,z), where x, y and z are three vectors of the same length,
plots a line in 3-space through the points whose coordinates are the
elements of x, y and z.

PLOT3(X,Y,Z), where X, Y and Z are three matrices of the same size,
plots several lines obtained from the columns of X, Y and Z.

Various line types, plot symbols and colors may be obtained with
PLOT3(X,Y,Z,s) where s is a 1, 2 or 3 character string made from
the characters listed under the PLOT command.

PLOT3(x1,y1,z1,s1,x2,y2,z2,s2,x3,y3,z3,s3,...) combines the plots
defined by the (x,y,z,s) fourtuples, where the x's, y's and z's are
vectors or matrices and the s's are strings.

Example: A helix:

t = 0😛i/50:10*pi;
plot3(sin(t),cos(t),t);

PLOT3 returns a column vector of handles to LINE objects, one
handle per line. The X,Y,Z triples, or X,Y,Z,S quads, can be
followed by parameter/value pairs to specify additional
properties of the lines.

See also PLOT, LINE, AXIS, VIEW, MESH, SURF.

An example: plot3([1,2],[1,2],[1,2])

that plots from (1,1,1) to (2,2,2)

Crypticburn

 
Originally posted by: Crypticburn
How about typing "help plot3":

PLOT3 Plot lines and points in 3-D space.
PLOT3() is a three-dimensional analogue of PLOT().

PLOT3(x,y,z), where x, y and z are three vectors of the same length,
plots a line in 3-space through the points whose coordinates are the
elements of x, y and z.

PLOT3(X,Y,Z), where X, Y and Z are three matrices of the same size,
plots several lines obtained from the columns of X, Y and Z.

Various line types, plot symbols and colors may be obtained with
PLOT3(X,Y,Z,s) where s is a 1, 2 or 3 character string made from
the characters listed under the PLOT command.

PLOT3(x1,y1,z1,s1,x2,y2,z2,s2,x3,y3,z3,s3,...) combines the plots
defined by the (x,y,z,s) fourtuples, where the x's, y's and z's are
vectors or matrices and the s's are strings.

Example: A helix:

t = 0😛i/50:10*pi;
plot3(sin(t),cos(t),t);

PLOT3 returns a column vector of handles to LINE objects, one
handle per line. The X,Y,Z triples, or X,Y,Z,S quads, can be
followed by parameter/value pairs to specify additional
properties of the lines.

See also PLOT, LINE, AXIS, VIEW, MESH, SURF.

An example: plot3([1,2],[1,2],[1,2])

that plots from (1,1,1) to (2,2,2)

Crypticburn

Oh, I see now, I just got the formatting wrong. I did look at the help file btw. 🙂 Thanks a lot!
 
Back
Top