How to draw lines in matlab

Suppose x axis values are (30,40,50) and its corresponding y-axis values are (100,200,300). How to draw three different line in a plot with (30,100) one line,(40,200) one line and (50,300) one line. Thank you.

Risposte (1)

KSSV
KSSV il 27 Lug 2018
Modificato: KSSV il 27 Lug 2018
X = [30,40,50] ;
Y = [100,200,300] ;
plot(X,Y,'.-r')
REad about plot

6 Commenti

Aditya Shau
Aditya Shau il 27 Lug 2018
Modificato: Aditya Shau il 27 Lug 2018
The plot should be like vertical lines..I have attached a sample
KSSV
KSSV il 27 Lug 2018
Vertical lines? YOu need to have data to plot what you have shown in figure.
Aditya Shau
Aditya Shau il 27 Lug 2018
Modificato: Aditya Shau il 27 Lug 2018
Sorry, it is horizontally. Suppose x - axis the min and max values are 10 to 50 at an interval of 10, i.e. 10:10:50. similarly, in y-axis 100:100:500(interval of 100).
Now, how do we plot for the given data.
KSSV
KSSV il 27 Lug 2018
Modificato: KSSV il 27 Lug 2018
x = 10:10:50. ;
y = 100:100:500 ;
[X,Y] = meshgrid(x,y) ;
plot(Y,X,'k')
Aditya Shau
Aditya Shau il 27 Lug 2018
let me make my question clear..in x-axis I have some values and y-axis some values. I want to draw a continuous line from a point of the x-axis to y-axis. so,suppose we have to draw the contiious line from x-axis value (let 30) to yaxis value (let 100).. like in the attachment.i need to only connect the points through continious line.
Wilmar Lima
Wilmar Lima il 11 Nov 2019
X = [30,0];
Y = [0,100];
plot(X,Y,'.-r') A red line

Accedi per commentare.

Richiesto:

il 27 Lug 2018

Commentato:

il 11 Nov 2019

Community Treasure Hunt

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

Start Hunting!

Translated by