How can I change the length of a line using the xline() function?
조회 수: 26 (최근 30일)
이전 댓글 표시
Recently, I was trying to make a graph wihich required a vertical line to be of a specific length (so it stops at a line plot, and not cut through). Coudn't find any functions. How can I do that?
xline([1336.5 648],"r--")
(The part that I want to remove)
댓글 수: 3
Umar
2024년 7월 9일
It’s okay, Md. Sounds like your problem is resolved. Good luck with your project. If you still have any further questions, we are still here to help you out.
채택된 답변
Sam Chak
2024년 7월 9일
Hi @Md Affan
Since you know the coordinates, you can directly use the plot() function.
% plot([x1, x2], [y1, y2]) creates a line between (x1, y1) and (x2, y2)
plot([1336.5 1336.5], [350 648], 'r--'), ylim([350 700]), grid on
추가 답변 (1개)
Shreshth
2024년 7월 9일
Dear Affan,
I can see that you are trying to introduce vertical lines in your graph with specific X and Y values.
There is not a direct line functionality that provides control over the vertical plot for your use case but one way of doing it is by using discrete data plots like "Stem Plots". You can find the functions associated with it in the following MathWorks documentation link, http://www.mathworks.com/help/matlab/stem-and-stair-plots.html.
Hope it helps.
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!