Need help with Matlab

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
How can I plot a line, or a range of values that are vertical (like a line) ? It doesn't say anything about lines when I looked in the help file.
 

StormRider

Diamond Member
Mar 12, 2000
8,324
2
0
I'm not sure I understand your question. You mean just a regular line to connect a series of data points?

If so, then I think it's plot or something like that...
 

StormRider

Diamond Member
Mar 12, 2000
8,324
2
0
What sort of parameters do you want to use to specify the line?

If you know 2 points on the line then you can use plot to draw that line.
 

jahawkin

Golden Member
Aug 24, 2000
1,355
0
0
make 2 variables, say a and b
define them as:
a = [1,5]
b = [1,5]
plot(a,b,'-')
I think the '-' command plots a line, but do a help plot command to see the different options

that should do it
 

StormRider

Diamond Member
Mar 12, 2000
8,324
2
0
Okay, Matlab is kind of weird when you first start out. Matlab is vector oriented.

Now, I'm assuming you want to plot the line between the points (1,1) and (5,5).

So, you have 2 x-coordinates and 2 y-coordinates.

Type this into Matlab:

x = [1 5]
y = [1 5]


The above tells Matlab that the x coordinates are 1 and 5 and the y coordinates are 1 and 5.

Now, tell Matlab to plot these data points by typing:

plot(x,y)
 

jahawkin

Golden Member
Aug 24, 2000
1,355
0
0
Correction to my prior post
Stormrider is correct, you do not need commas between your values when defining your arrays.
And, like he said, it takes a while to get used to the matrix orientation of everything, but once you do, its really easy.