generate a matrix along the length of an inclined line
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ace_ventura
le 13 Fév 2015
Commenté : Ace_ventura
le 13 Fév 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?
0 commentaires
Réponse acceptée
Michael Haderlein
le 13 Fév 2015
Modifié(e) : Michael Haderlein
le 13 Fév 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!