Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Matlab] How to draw a line in plot?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
matlab plot line

Hello all,

How to draw a line in plot when I know the start point(x1,y1) and end point(x2,y2)?

Thanks!
Davy
 

matlab draw line

Hej Davy

Lets say you want a line with coordinates (x1,y1) and (x2,y2). Then you make a vector with the x and y coordinates: x = [x1 x2] and y=[y1 y2].
Matlab has a function called 'Line', this is used in this way:
line(x,y)
I generates a plot with the two points and a line that connects them.

Hopes this helped.

Regards
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
plot line matlab

no line function is neccessary. plot byitself make an linear interpolation between points so only try
plot([x1,x2],[y1,y2]).
 

draw line matlab

Hello!

I got a similar problem

I want to form my initials (JCBD) but with a custom path. So I need to put some points in a plot and them connect them with lines so that the 4 letters are formed

how do I do this?
 

matlab line plot

y=x is linear equation

It is on a x axis


y=2x its going up
 

plot line in matlab

I believe that the line(x,y) funtion in matlab can be overloaded to be used as a 3D function and thus be used as line(x,y,z). As stated the plot function will linearly interpolate but sometimes this is not desired. As an example animation using the line function will be more smooth than similar animations using the plot command. It all depends on what you want to do with the line.

Cheers
Slayer
 

draw line in matlab

Here is a answer for ur Query......

just use the format

PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up.
PLOT(Y) plots the columns of Y versus their index.
If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)).
In all other uses of PLOT, the imaginary part is ignored.
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 colunms:
y yellow . point - solid
m magenta o circle : dotted
c cyan x x-mark -. dashdot
r red + plus -- dashed
g green * star
b blue s square
w white d diamond
k black v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, PLOT(X,Y,’c+:’) plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,’bd’) plots blue diamond at each data
point but does not draw any line.
PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,...) combines the plots defined by
the (X,Y,S) triples, where the X’s and Y’s are vectors or matrices
and the S’s are strings.
For example, PLOT(X,Y,’y-’,X,Y,’go’) plots the data twice, with a
solid yellow line interpolating green circles at the data points.
 
  • Like
Reactions: zdshkr

    zdshkr

    Points: 2
    Helpful Answer Positive Rating
how to draw a line in matlab

aztroboy, here's a simple letter 'J'. You can expand it into more letters.

plot([5 5 4 3 2],[8 2 1 1 2],'k', [4 6],[8 8],'k'); xlim([0 10]); ylim([0 10]);
 
Re: how to draw a line in matlab

aztroboy, here's a simple letter 'J'. You can expand it into more letters.

plot([5 5 4 3 2],[8 2 1 1 2],'k', [4 6],[8 8],'k'); xlim([0 10]); ylim([0 10]);

thanks a lot faztroboy

by your answer I did this


xlim([5 100]); ylim([5 100]); ------:arrow:----- Draw (x,y) axis

plot([5 5 4 3 2],[8 2 1 1 2],'k', [4 6],[8 8],'k'); xlim([0 10]); ylim([0 10]); --:arrow:-- Draw (J) letter --- k is ( black color of line )

plot([5 5 4 3 2],[8 2 1 1 2],'R', [4 6],[8 8],'R'); xlim([0 10]); ylim([0 10]);---:arrow:--- Draw (J) letter --- R is ( Red color of line )

plot([4 6],[8 8],'R'); xlim([0 10]); ylim([0 10]); --:arrow:---- Draw strait line ----- Red color

plot([2 9],[5 5],'K',[2 9],[4 4],'R'); xlim([0 10]); ylim([0 10]); --:arrow:------ Draw 2 straight lines ----- Red & black color

plot([4 8],[7 7],'K',[4 4],[3 7],'R',[4 8],[3 3],[8 8],[3 7],'R'); xlim([0 10]); ylim([0 10]); --:arrow:-- Draw square
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top