Phase Potrait
-
Upload
tanzeel-shakeel -
Category
Documents
-
view
223 -
download
0
Transcript of Phase Potrait
-
8/12/2019 Phase Potrait
1/10
-
8/12/2019 Phase Potrait
2/10
%%% ------ ***** Tanzeela Shakeel****----------%%%%%%%------- **** FA13-MSEE-019 *****------------%%%%%%%------- **** Assignment #1 *****------------%%%%%%%------- ****Date: 13-03-2014 ****------%%%%%%%------- **** Non Linear Control System ****------%%%%%%%------- **** Phase portrait ****------%%%%
Question #1
functiondy=myfunc(t,y)clcclose alldy(1)=y(2);dy(2)=-3*y(1)-y(2)-y(1)*y(1);
dy=dy';return
Calling Function file code Q# 1
clcclose all
options=odeset('Maxstep',0.01);[t,y]=ode45('myfunc',[0,20],[-2;4],options);[t1,y1]=ode45('myfunc',[0,20],[-2;6],options);[t2,y2]=ode45('myfunc',[0,20],[2;6],options);
figureplot(y2(:,1),y2(:,2),'g',y1(:,1),y1(:,2),'r', y(:,1),y(:,2),'b')
title('Phase Potrait of Q1') % titlelegend('initial condition 2', 'initial condition 1','initial condition ')legend('Location','NorthWest') % move legend to upper left
figure
plot(t, y(:,1),'r')hold on
plot(t,y(:,2),'b')title('time potrait of Q1') % title
legend('initial condition1 y1','initial condition1 y2')
legend('Location','NorthWest') % move legend to upper leftfigure
plot(t1, y1(:,1),'r')hold onplot(t1,y1(:,2),'b')title('time potrait of Q1') % title
legend('initial condition1 y1','initial condition1 y2')legend('Location','NorthWest') % move legend to upper left
figure
-
8/12/2019 Phase Potrait
3/10
plot(t2, y2(:,1),'r')hold onplot(t2,y2(:,2),'b')
title('time potrait of Q2') % titlelegend('initial condition1 y1','initial condition1 y2')legend('Location','NorthWest') % move legend to upper left
Figure
Question #2
functiondx=myfu(t,x)clcclose alldx(1)=x(2);%e=0.1;e=1.0%e=5.0;dx(2)=-x(1)+e*(1-x(1)*x(1))*x(2);dx=dx';
-3 -2 -1 0 1 2 3 4-6
-4
-2
0
2
4
6
Phase Potrait of Q1
initial condition 2
initial condition 1
initial condition
0 2 4 6 8 10 12 14 16 18 20-2
-1
0
1
2
3
4
time potrait of Q1
initial condition1 y1
initial condition1 y2
-
8/12/2019 Phase Potrait
4/10
return
Calling Function file code Q# 2
options=odeset('Maxstep',0.01);[t,x]=ode45('myfu',[0,20],[-2;4],options);% figure
% plot(x(:,1),x(:,2));
[t1,x1]=ode45('myfu',[0,20],[-2;6],options);
% figure%plot(x1(:,1),x1(:,2),'r', x(:,1),x(:,2))
[t2,x2]=ode45('myfu',[0,20],[2;6],options);
figureplot(x2(:,1),x2(:,2),'g',x1(:,1),x1(:,2),'r', x(:,1),x(:,2),'b')title('Phase Potrait of Q2') % title
legend('initial condition 2', 'initial condition 1','initial condition ')legend('Location','NorthWest') % move legend to upper left
figure
plot(t, x(:,1),'r')hold on
plot(t,x(:,2),'b')title('time potrait of Q2') % title
legend('initial condition1 x1','initial condition1 x2')legend('Location','NorthWest') % move legend to upper left
figure
plot(t1, x1(:,1),'r')hold onplot(t1,x1(:,2),'b')
title('time potrait of Q2') % titlelegend('initial condition1 x1','initial condition1 x2')legend('Location','NorthWest') % move legend to upper left
figure
plot(t2, x2(:,1),'r')hold onplot(t2,x2(:,2),'b')
title('time potrait of Q2') % title
legend('initial condition1 x1','initial condition1 x2')legend('Location','NorthWest') % move legend to upper left
Figure
-
8/12/2019 Phase Potrait
5/10
Question #3
functiondy =funct(t,y)
clcclose all%y(1)=y%y(2)=dydy(1)=y(2);
ify(1)*y(2)>0
dy(2)= -(2*y(1))
else
dy(2)=-(1/2*(y(1)))
enddy=dy'
return
Calling Function file code Q# 3
-3 -2 -1 0 1 2 3-3
-2
-1
0
1
2
3
4
5
6
7
Phase Potrait of Q2
initial condition 2
initial condition 1
initial condition
0 2 4 6 8 10 12 14 16 18 20-3
-2
-1
0
1
2
3
4
5
time potrait of Q2
initial condition1 x1
initial condition1 x2
-
8/12/2019 Phase Potrait
6/10
clcclose all
options=odeset('Maxstep',0.01);[t,y]=ode45('funct',[0,20],[-2;4],options);%figure
% plot(y(:,1),y(:,2));
% [t1,y1]=ode45('funct',[0,20],[-2;6],options);
%figure%plot(y1(:,1),y1(:,2),'r', y(:,1),y(:,2))
[t2,y2]=ode45('funct',[0,20],[2;6],options);
figureplot(y2(:,1),y2(:,2),'g',y1(:,1),y1(:,2),'r', y(:,1),y(:,2),'b')title('Phase Potrait of Q3') % title
legend('initial condition 2', 'initial condition 1','initial condition ')legend('Location','NorthWest') % move legend to upper left
figure
plot(t, y(:,1),'r')hold on
plot(t,y(:,2),'b')
title('time potrait of Q3') % titlelegend('initial condition y1','initial condition y2')legend('Location','NorthWest') % move legend to upper left
figure
plot(t1, y1(:,1),'r')hold onplot(t1,y1(:,2),'b')
title('time potrait of Q3') % titlelegend('initial condition1 y1','initial condition1 y2')legend('Location','NorthWest') % move legend to upper left
figure
plot(t2, y2(:,1),'r')hold onplot(t2,y2(:,2),'b')
title('time potrait of Q3') % titlelegend('initial condition1 y1','initial condition1 y2')legend('Location','NorthWest') % move legend to upper left
-
8/12/2019 Phase Potrait
7/10
Figure
Question #4functiondy =func(t,y)clcclose all%y(1)=y%y(2)=dydy(1)=y(2);
ify(1)+y(2)>0
dy(2)= -1 ;
elsey(1)+y(2)
-
8/12/2019 Phase Potrait
8/10
Calling Function file code Q# 3
clcclose all
options=odeset('Maxstep',0.01);[t,y]=ode45('func',[0,20],[-2;4],options);%figure%plot(y(:,1),y(:,2));
[t1,y1]=ode45('func',[0,20],[-2;6],options);
%figure%plot(y1(:,1),y1(:,2),'r', y(:,1),y(:,2))
[t2,y2]=ode45('func',[0,20],[2;6],options);
figureplot(y2(:,1),y2(:,2),'g',y1(:,1),y1(:,2),'r', y(:,1),y(:,2),'b')
title('Phase Potrait of Q4') % titlelegend('initial condition 2', 'initial condition 1','initial condition ')legend('Location','NorthWest') % move legend to upper left
% time potrait
figure
plot(t, y(:,1),'r')hold on
plot(t,y(:,2),'b')title('time potrait of Q4') % titlelegend('initial condition y1','initial condition y2')legend('Location','NorthWest') % move legend to upper left
figure
plot(t1, y1(:,1),'r')hold onplot(t1,y1(:,2),'b')
title('time potrait of Q4') % titlelegend('initial condition1 y1','initial condition1 y2')legend('Location','NorthWest') % move legend to upper left
figure
-
8/12/2019 Phase Potrait
9/10
plot(t2, y2(:,1),'r')hold onplot(t2,y2(:,2),'b')title('time potrait of Q4') % title
legend('initial condition2 y1','initial condition2 y2')legend('Location','NorthWest') % move legend to upper left
Figure
-10 -5 0 5 10 15 20 25-6
-4
-2
0
2
4
6
Phase Potrait of Q4
initial condition 2
initial condition 1
initial condition
0 2 4 6 8 10 12 14 16 18 20-3
-2
-1
0
1
2
3
4
5
6
7
time potrait of Q4
initial condition y1
initial condition y2
-
8/12/2019 Phase Potrait
10/10
Question #5
Figure: