generate a matrix along the length of an inclined line

1 visualización (últimos 30 días)
Ace_ventura
Ace_ventura el 13 de Feb. de 2015
Comentada: Ace_ventura el 13 de Feb. de 2015
I have an inclined line of a given length 'L' in XY coordinate plane, at a certain angle alpha with global X axis.My input would be a certain length say 's' and I want to generate a matrix which contains X and Y coordinates along the line at a distance 's' that I have inputted. So, basically the coordinates are at a spacing of 's' along the line of length 'L'. How can i get that matrix?

Respuesta aceptada

Michael Haderlein
Michael Haderlein el 13 de Feb. de 2015
Editada: Michael Haderlein el 13 de Feb. de 2015
I hope I got your question right. I suppose you have a line originating at (x0/y0) with an angle alpha and a length L:
L=5;alpha=pi/6;
x0=2;y0=1;
figure, hold all
plot([x0 x0+L*cos(alpha)],[y0 y0+L*sin(alpha)])
axis equal
Secondly, you have a distance s smaller than L and you want all steps of size s on that original line, right?
s=.5;
xs=x0+(0:s:L)*cos(alpha);
ys=y0+(0:s:L)*sin(alpha);
plot(xs,ys,'o')
If you don't want (x0/y0) to be part of (xs/ys), just increment starting from s instead of starting from 0.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by