sliding mode phase plane

13 ビュー (過去 30 日間)
Murtadha Abushahin
Murtadha Abushahin 2014 年 9 月 4 日
コメント済み: Murtadha Abushahin 2014 年 9 月 11 日
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
Murtadha Abushahin 2014 年 9 月 5 日
@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
Murtadha Abushahin 2014 年 9 月 6 日
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 Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by