How plot a line segment with arrowhead?
이전 댓글 표시
Hey do I plot line segments like in this picture? And maybe could tell me someone how to do the arrows?

답변 (1개)
Image Analyst
2022년 12월 11일
편집: Image Analyst
2022년 12월 11일
0 개 추천
To plot arrows, you can use annotation
댓글 수: 4
N/A
2022년 12월 12일
You can plot many lines with plot but you have to put a nan in between the points. I'm not sure that's easier than just plotting in a loop. It's probably not but here is how you can do it
x = 1:10;
y = randi(9, 1, length(x));
subplot(2, 1, 1);
plot(x, y, 'b.-', 'LineWidth', 2, 'MarkerSize', 18);
grid on;
% Make a section nan so it won't draw a line there.
hiddenrange = 5:7;
x(hiddenrange) = nan;
y(hiddenrange) = nan;
subplot(2, 1, 2);
plot(x, y, 'b.-', 'LineWidth', 2, 'MarkerSize', 18); % Nan values won't draw
grid on;
Brian LaRocca
2024년 11월 27일
Using annotate with data drawn using plot is awkward since the two do not share the same coordinate system.
Brian LaRocca
2024년 11월 27일
quiver and quiver3 get around this, but the arrows may not look that great. There should be a better solution.
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
