generate a matrix along the length of an inclined line
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Michael Haderlein
2015년 2월 13일
편집: Michael Haderlein
2015년 2월 13일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!