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!