How would you call this function?

1 Ansicht (letzte 30 Tage)
Crisa Hale
Crisa Hale am 3 Dez. 2017
Beantwortet: Greg am 5 Dez. 2017
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

Antworten (1)

Greg
Greg am 5 Dez. 2017
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.

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by