How to draw a line in Scilab

Engine picture Engine · Oct 22, 2012 · Viewed 11.6k times · Source

I'm trying to plot a line between two points: a(xa,ya) and b(xb,yb). How can I do that in Scilab?

Thanks in advance for your help

Answer

xenoclast picture xenoclast · Oct 24, 2012

I find it convenient to do this with the plot command. Assemble your vertices as arrays of [x0 x1 x2 x3 ...] and [y0 y1 y2 y3 ...] and then feed them into plot.

So to draw a line from (0,0) to (30,40) you could use:

xpts = [0 30];
ypts = [0 40];

plot(xpts, ypts);

You can give it matrices to have it plot multiple lines in one command - type help plot in the console to get the specifics of the row/column conventions.