Draw a straight line from the center (0,0) 25 degrees in the coordinate system
조회 수: 3 (최근 30일)
이전 댓글 표시
I don't have any experience in Matlab but I need to measure distances for a simulation. I ask for your support. From the center of the coordinate system (0,0) I have to draw a straight line that is 4m long as an orientation. Then a straight line from the left side that starts at the point (-1.0), 25 degrees from the center line and ends at the end of the 4m straight. So also from the right side a straight line with the beginning (1.0) and also ends at 4m.
I have to move the starting points (-1.0) and (1.0) after each measurement of the distance of the line from its starting points for the next measurement. For example: the next starting points of the two lines from the left and right start at (-2.0) and (2.0).
I have an example in the appendix.
And then, finally, for each angle from 0 degrees to 25 degrees from the center (0.0), perform the displacements on the X-axis. For example, starting with (-1.0) and (1.0) to (-5.0) and (5.0) I will upload example in the attachment.
Thank you in advance!
댓글 수: 0
답변 (1개)
Harald
2024년 4월 5일
Hi,
I suppose you are fine calculating start and end points of each line?
plot([x1, x2], [y1, y2])
will draw a line from (x1, y1) to (x2, y2). When using multiple plot commands, make appropriate use of the hold command.
Best wishes,
Harald
댓글 수: 2
Harald
2024년 4월 8일
Hi,
in my suggestion, use
x1 = 0;
y1 = 0;
x2 = cosd(theta) * d;
y2 = sind(theta) * d;
If different scaling is used on the axes, the angle may look incorrect. To prevent that, use
axis equal
Best wishes,
Harald
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!