I wanted to generate a line from start to end position on which there would be random points over the line and nearby with in some distance, not over the whole area.
1 次查看(过去 30 天)
显示 更早的评论
I wanted a code which generate nodes and sample them which will track the optimal path by using those random generated nodes on line or nearby that line.
basically i wanted to merge the following code with my RRT* algorithm to limit the researches. If any one could help me out of it.
numPoints = 50;
x = sort(5 * rand(1, numPoints), 'ascend');
m = 0.4;
c = 3;
y = m*x+c;
plot(x, y, 'bd-', 'LineWidth', 2);
grid on;
hold on;
amplitude = 1.6; % Whatever...
noise = amplitude * rand(1, length(y)) - amplitude / 2;
plot(x, noise, 'ms-'); % Plot noise
yNoisy = y + noise;
plot(x, yNoisy, 'r.', 'LineWidth', 2, 'MarkerSize', 10);
ax = gca;
ax.XAxisLocation = 'origin';
0 个评论
回答(1 个)
Anurag
2023-8-29
As per my understanding of the question you need to have the random points nearby the lines but not all over the space, for this you can limit the coordinates of the points being generated.
Suppose you need the points that fall within a close vicinity of the center of the line, you may iterate through your list of points and remove those x coordinates that fall outside your defined threshold from the midpoint of the point.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!