Draw a straight line from the center (0,0) 25 degrees in the coordinate system
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Harald
el 5 de Abr. de 2024
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 comentarios
Harald
el 8 de Abr. de 2024
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
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!