MATLAB Answers

How to insert arrows at the middle of each of the parallel lines

28 views (last 30 days)
Atom
Atom on 7 Jul 2020 at 7:29
Commented: Atom on 8 Jul 2020 at 7:23
In the follwoing I want to insert arrows at the middle of each of the parallel lines
p = 0.01:.05:1;
figure(1)
plot([0; 1],[p; p], 'color','b');
x = [0.3,0.5];
y = [p,p+0.1];
a = annotation('arrow',x,y);
How to do that ? But my code does not work

  3 Comments

KSSV
KSSV on 7 Jul 2020 at 11:00
Can you show a pictorial example of what you expect?
Atom
Atom on 7 Jul 2020 at 11:22
The example is like this. I have to draw parallel lines to x-axis and insert arrows like the fig in the middle of the each line.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 8 Jul 2020 at 3:49
Edited: KSSV on 8 Jul 2020 at 5:27
Why annotation for this? You can use quiver. Play around with the below code.
clc; clear all ;
p = 0.01:.05:1;
x =[0;1] ;
y = [p ;p] ;
x1 = repmat(0.5,1,20);
y1 = p ;
u1 = -0.2*ones(size(y1)) ;
v1 = zeros(size(x1)) ;
figure(1)
hold on
plot(x,y, 'color','b');
quiver(x1,p,u1,v1)
quiver(x1+0.1,p,u1,v1)

  3 Comments

Atom
Atom on 8 Jul 2020 at 7:10
Thank you. I would like to change the arrow shape as per the fig I have attached before. Possible?
KSSV
KSSV on 8 Jul 2020 at 7:17
That would be tough using quiver...but you can try changing the width of the arrow, read the documentation.

Sign in to comment.

More Answers (1)

Mehmed Saad
Mehmed Saad on 7 Jul 2020 at 11:09
Edited: Mehmed Saad on 7 Jul 2020 at 11:26

  2 Comments

Atom
Atom on 7 Jul 2020 at 12:56
Thank you but it is not what I need. I have to draw parallel lines to x-axis and insert arrows like the fig in the middle of the each line as shown in the fig above.

Sign in to comment.

Tags