generate a matrix along the length of an inclined line

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Michael Haderlein
Michael Haderlein il 13 Feb 2015
Modificato: Michael Haderlein il 13 Feb 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.

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by