G4bri3l
G4bri3l

Reputation: 5146

Draw a portion of a line in Matlab

I just wanna draw a portion of a line. I'll try to be more specific.

enter image description here

Now I wanna see just a portion of the red line..but I don't know how to do it in Matlab. I wanna show like a little portion around the red dot.

Upvotes: 1

Views: 185

Answers (2)

Andrey Rubshtein
Andrey Rubshtein

Reputation: 20915

Use plot command:

  x = [0 3];
  y = [1 -4];
  plot(x,y,'r');

In order to draw 2 shapes together, use hold on:

  x = -2*pi:0.01:2*pi;
  y = sin(x);
  plot(x,y,'k');
  hold on;
  x = [0 3];
  y = [1 -4];
  plot(x,y,'r');

Upvotes: 2

Rasman
Rasman

Reputation: 5359

use line to draw what you need. Say you want to draw a point going from (0,1) to (3,-4), type:

line ([0 3], [1 -4])

Upvotes: 1

Related Questions