Animate a movin rectangle car like model

조회 수: 11 (최근 30일)
Shabnam
Shabnam 2018년 9월 19일
댓글: islam dib 2020년 12월 13일
hi
I need to model 3 cars, 2 are not moving and the third should be parked between them. I mean the third one should follow a fifth order polynomial path.

채택된 답변

KSSV
KSSV 2018년 9월 19일
L = 1. ; B = 2. ;
C = [0. 0. ; L 0. ; L B ; 0. B; 0 0.] ;
C1 = [0. 0]+C ;
C2 = [0. 5.]+C ;
C3 = [0. 10.]+C ;
path = rand(10,2) ;
for i = 1:10
plot(C1(:,1),C1(:,2),'r')
hold on
plot(C2(:,1)+path(i,1),C2(:,2)+path(i,2),'b')
plot(C3(:,1),C3(:,2),'g')
hold off
axis([-10 10 0 20])
drawnow
pause(0.5)
end
  댓글 수: 4
Hanaa Jabbar
Hanaa Jabbar 2020년 5월 22일
How I make the second car passes the third car in mind, which changes its right movement or left when you reach the third car
islam dib
islam dib 2020년 12월 10일
I ve used this code
L = 1. ; B = 2. ;
C = [0. 0. ; L 0. ; L B ; 0. B; 0 0.] ;
C1 = [0. 0]+C ;
C2 = [0. 5.]+C ;
C3 = [0. 10.]+C ;
path = rand(10,2) ;
for i = 1:10
plot(C1(:,1),C1(:,2),'r')
hold on
plot(C2(:,1)+path(i,1),C2(:,2)+path(i,2),'b')
plot(C3(:,1),C3(:,2),'g')
hold off
axis([-10 10 0 20])
drawnow
pause(0.5)
end
and I got this error
>> plot8cqr
Error using +
Matrix dimensions must agree.
Error in plot8cqr (line 3)
C1 = [0. 0]+C ;

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

islam dib
islam dib 2020년 12월 7일
I got this error !!
Error using +
Matrix dimensions must agree.
Error in Untitled (line 3)
C1 = [0. 0]+C ;
  댓글 수: 4
KSSV
KSSV 2020년 12월 11일
This is not showing any error. It ran sucessfully.
L = 1. ; B = 2. ;
C = [0. 0. ; L 0. ; L B ; 0. B; 0 0.] ;
C1 = [0. 0]+C ;
C2 = [0. 5.]+C ;
C3 = [0. 10.]+C ;
path = rand(10,2) ;
for i = 1:10
plot(C1(:,1),C1(:,2),'r')
hold on
plot(C2(:,1)+path(i,1),C2(:,2)+path(i,2),'b')
plot(C3(:,1),C3(:,2),'g')
hold off
axis([-10 10 0 20])
drawnow
pause(0.5)
end
islam dib
islam dib 2020년 12월 13일
I'm using Matlab 2013b, I think this is the problem, isn't ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by