MATLAB Answers

Making moving obstacles in an matlab

54 ビュー (過去 30 日間)
faiza gul
faiza gul 2019 年 1 月 2 日
編集済み: Pravija Raj 2019 年 9 月 19 日
I have created random obstacles in MATLAB, (they are user acquired) now I am trying to make some obstacles randomly moving.
I Know that, in every iteration value of some obstacle be updated by adding some threshold valueto it.
But I am getting how to write up in code.
Kindly help me

  12 件のコメント

表示 9 件の古いコメント
faiza gul
faiza gul 2019 年 1 月 4 日
The last part that you mentioned is so correct that exactly I want for my simulation. Like obstacles should move with random speed.
Can you help how should I do this
Pravija Raj
Pravija Raj 2019 年 8 月 19 日
Hello Faiza,
I am working with a similar situation. Were you able to figure out the code for your scenario. Please kindly share if you have.
I will explain my problem here. I need to simulate an object that randomly moves in a square area in any direction for a duration of time with a random speed. Can any one help me with the code for this.
faiza gul
faiza gul 2019 年 9 月 10 日
I am working on path planning and avoiding obstacle.



darova 2019 年 9 月 10 日
After long 7 month of training and research i reached a success. Here is what i've achieved
px = 5*rand(10,1); % initial position
py = 5*rand(10,1);
axis([-1 1 -1 1]*20)
hold on
t = 360*rand(size(px)); % initial direction in degree
for i = 1:20 % number of iterations
dx = 0.5*cosd(t); % how fast we move
dy = 0.5*sind(t);
t = t + 90*(0.5-rand(size(px))); % change direction (-45:45) degree
plot([px px+dx]', [py py+dy]') % plot displacement
px = px + dx; % new position
py = py + dy;
h = plot(px,py,'.b'); % plot new position
pause(0.2) % wait
delete(h) % remove new position
% from graph
hold off

  3 件のコメント

faiza gul
faiza gul 2019 年 9 月 10 日
Thats amazing and exceptional. truly good work
darova 2019 年 9 月 10 日
Thank you :)
Pravija Raj
Pravija Raj 2019 年 9 月 19 日
Many thanks for your response and really appreciate your work.
Thank you.


その他の回答 (0 件)


Community Treasure Hunt

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

Start Hunting!

Translated by