Draw a straight line from the center (0,0) 25 degrees in the coordinate system
2 次查看(过去 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 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!