sliding mode phase plane

12 次查看(过去 30 天)
how can i plot phase plane trajectory of sliding mode controller .
  2 个评论
Aykut Satici
Aykut Satici 2014-9-4
I would simulate a second-order ode with a sliding mode controller and then plot the two states against each other.
Murtadha Abushahin
@aykut satici how can i do that ??
right now i have two separates m.file as shown below
1- function [sys,x0,str,ts] = spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts]=mdlInitializeSizes; case 3, sys=mdlOutputs(t,x,u); case {2,4,9} sys=[]; otherwise error(['Unhandled flag = ',num2str(flag)]); end function [sys,x0,str,ts]=mdlInitializeSizes; sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 5; sizes.NumInputs = 2; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 0; sys = simsizes(sizes); x0 = []; str = []; ts = []; function sys=mdlOutputs(t,x,u) r=0; dr=0; ddr=0; x=u(1); dx=u(2); e=r-x; de=-dx;
F = @(t) e;
q=integral(F,0,t,'ArrayValued',true);
k=0.78;
tau=230;
T=6;
lambeda=0.16235014489;
kd=10.44705253128305;
siegma=0.68+0.12*abs(k)*kd*2*lambeda;
fx=-0.3381*x-0.0014*dx;
s=sign(k)*(de)+(2*(lambeda^2)*e)+((lambeda^2)*q);
ds=-sign(k)*(k*kd/1380)*(s/(abs(s)+siegma));
uc=(-2*(lambeda)*de)+((-lambeda^2)*e)+fx;
ud=kd*(s/(abs(s)+siegma));
ut=uc+ud;
sys(1)=ut;
sys(2)=e;
sys(3)=de;
sys(4)=s;
sys(5)=ds;
2- function [sys,x0,str,ts]=s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts]=mdlInitializeSizes; case 1, sys=mdlDerivatives(t,x,u); case 3, sys=mdlOutputs(t,x,u); case {2, 4, 9 } sys = []; otherwise error(['Unhandled flag = ',num2str(flag)]); end function [sys,x0,str,ts]=mdlInitializeSizes ; sizes = simsizes; sizes.NumContStates = 2; sizes.NumDiscStates = 0; sizes.NumOutputs = 2; sizes.NumInputs = 1; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 0; sys=simsizes(sizes); x0=[2 2]; str=[]; ts=[];
function sys=mdlDerivatives(t,x,u)
sys(1)=x(2);
sys(2)=-0.3381*x(1)-0.0014*x(2)+u;
function sys=mdlOutputs(t,x,u)
sys(1)=x(1);
sys(2)=x(2);

请先登录,再进行评论。

采纳的回答

Aykut Satici
Aykut Satici 2014-9-5
Would you like to do this in MATLAB or Simulink? I have worked through a baby example that is implemented in MATLAB, using the "ode45" solver.
You can find the problem that is worked in the attached PDF-file. The MATLAB codes that implement the control and plot the phase portrait are the M-files.
To start the simulation you need to run "slidingModeExampleRunner.m." This file just calls the code that performs the simulation ("slidingModeExample.m") and once it is done, it calculates the value of the function "s", which defines the sliding manifold, at each solution step. It then creates two plots, the first one is the phase portrait and the sliding manifold plotted on the same axes. The second one is the function "s" plotted against time.
The system's equations of motion, which are given by equation (1) in the PDF-file, are coded in the M-file "slidingModeSystemEoM." You can see that the control law is implemented here, too. These ODEs are then fed into MATLAB's ODE solver "ode45" within the file "slidingModeExample.m", where I have defined the various constants and initial conditions used for the problem.
  2 个评论
Murtadha Abushahin
thank you for your answer it was very helpful !!
i got one more question, i'm trying to plot the control input, but i'm getting a zero value in the figure while when i cheek it in the simulink it is not !
Murtadha Abushahin
Murtadha Abushahin 2014-9-11
@Aykut Statici
how can i plot the control input signal using the M file??

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Pole and Zero Locations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by