Question
function [t,x]=H4_PotentialNavigation() clc time=[0 300]; x0=[0;0;0]; [t x]=ode23(@vehicle,time,x0); plot(x(:,1),x(:,2),'r',Goal(1),Goa1(2),'o',obs1(1),obs2(2),'x',obs2(1),obs2(2),'x') axis([0 12 0 12]) function dx=vehicle (t,x) Goal=[10;10]; obs1=[3;3]; obs2=[9;9]; KG=30; KO=30; rG=sqrt((Goal(1)-x(1))^2+(Goal(2)-x(2))^2); Fgx=KG*(Goal(1)-x(1))/rG; Fgy=KG*(Goal(2)-x(2))/rG; robs1=sqrt((obs1(1)-x(1))^2+(obs1(2)-x(2))^2);
function [t,x]=H4_PotentialNavigation()
clc
time=[0 300];
x0=[0;0;0];
[t x]=ode23(@vehicle,time,x0);
plot(x(:,1),x(:,2),'r',Goal(1),Goa1(2),'o',obs1(1),obs2(2),'x',obs2(1),obs2(2),'x')
axis([0 12 0 12])
function dx=vehicle (t,x)
Goal=[10;10];
obs1=[3;3];
obs2=[9;9];
KG=30;
KO=30;
rG=sqrt((Goal(1)-x(1))^2+(Goal(2)-x(2))^2);
Fgx=KG*(Goal(1)-x(1))/rG;
Fgy=KG*(Goal(2)-x(2))/rG;
robs1=sqrt((obs1(1)-x(1))^2+(obs1(2)-x(2))^2);
Fobs1x=-Ko*(obs1(1)-x(1))/robs1^3;
Fobs1y=-Ko*(obs1(2)-x(2))/robs1^3;
robs2=sqrt((obs2(1)-x(1))^2+(obs2(2)-x(2))^2);
Fobs2x=-Ko*(obs2(1)-x(1))/robs2^3;
Fobs2y=-Ko*(obs2(2)-x(2))/robs2^3;
Fx=(FGx+Fobs1x+Fobs2x);
Fy=(FGy+Fobs1y+Fobs2y);
alpha=atan(Fy/Fx);
v=1; L=2;
if rG<0.05
v=0;
end
K=2;
ph=K*(alpha-x(3));
dx= [v*cos(ph)*cos(x(3));v*cos(ph)*sin(x(3));v*sin(ph)/L];
end
end
this is a matlab code
I have errors in this code could you please fix it i want to see the plot
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started