I want to put arrows on each of the lines parallel to x-axis using LOOP

3 vues (au cours des 30 derniers jours)
Atom
Atom le 8 Nov 2022
Commenté : Atom le 8 Nov 2022
I want to put arrows on each of the lines parallel to x-axis using LOOP
Here I am able to put one arrow. Using
q = 0.2:.2:1;
xx = [0.56 0.57]; % adjust length and location of arrow
yy = [q q];
I failed to get the desired arrows. How to modify the code below to get arrows on each blue lines.
p = 0.02:.07:1;
plot([0; 1],[p; p], 'color','b');
%q = 0.2:.2:1;
xx = [0.56 0.57]; % adjust length and location of arrow
yy = [0.9 0.9];
annotation('textarrow',xx,yy,'FontSize',13,'Linewidth',2)
xlabel('$x\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$y\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
axis([0 1 0 .5]);

Réponse acceptée

Alan Stevens
Alan Stevens le 8 Nov 2022
Like this?
p = 0.02:.07:1;
plot([0; 1],[p; p], 'color','b');
hold on
%q = 0.2:.2:1;
xx = [0.5 0.57]; % adjust length and location of arrow
ly = 0.15; d = 0.0555;
for i=1:numel(p)
yy = [ly ly];
ly = ly+d;
annotation('textarrow',xx,yy,'FontSize',13,'Linewidth',2)
end
xlabel('$x\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')
ylabel('$y\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by