How would you call this function?
조회 수: 2 (최근 30일)
이전 댓글 표시
function robot_travel(V,w)
%Known Values a,r
%inputs V,w
a=13.5
w=10;%Unknown Value
r=10;%Unknown Value
tht=45;%Degree Theta Inital Rotation
Vr=((2*V)+(w*a))/(2*r);
Vl=((2*V)-(w*a))/(2*r);
xdt=r/2*(Vr+Vl)*cosd(tht);
ydt=r/2*(Vr+Vl)*sind(tht);
thtdt=r/2*(Vr-Vl);%THETA Value Unknown how it effects
axis([-100 100 -100 100])
square=[1 -1 1 -1;-1 1 1 -1];
plot(square(1,:),square(2,:),'*b')
n=50;
xdt=linspace(0,xdt,n);%Increments X and Y so graph can animate
ydt=linspace(0,ydt,n);
for i=1:n
plot(xdt(i)+square(1,:),ydt(i)+square(2,:),'*r')%Plots the change in square postion due to change in x and y
axis([-100 100 -100 100])
pause(.1)
end
hold on
plot(square(1,:),square(2,:),'*b')
hold off
end
I keep getting the following error:
Error using linspace (line 22)
Inputs must be scalars.
Error in robot_travel (line 19)
xdt=linspace(0,xdt,n);%Increments X and Y so graph can animate
댓글 수: 0
답변 (1개)
Greg
2017년 12월 5일
I didn't analyze for a more efficient solution, but move
xdt=linspace(0,xdt,n);%Increments X and Y so graph can animate
ydt=linspace(0,ydt,n);
inside your loop, and index xdt(i) ydt(i) as elsewhere.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!