0% found this document useful (0 votes)
53 views42 pages

Feedback Linearization

The document describes the process of feedback linearization control for nonlinear systems. It provides the functions LieDerivative and solvelieder to calculate Lie derivatives, which are used in the inoutfeedbacklinearization function to generate the feedback linearization controller. The user provides state space equations and output functions, which are symbolically represented and passed to inoutfeedbacklinearization to output the Lie derivatives and feedback linearization control law. A sample program TEST2 is also provided to demonstrate how a user would call the functions to analyze a specific system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views42 pages

Feedback Linearization

The document describes the process of feedback linearization control for nonlinear systems. It provides the functions LieDerivative and solvelieder to calculate Lie derivatives, which are used in the inoutfeedbacklinearization function to generate the feedback linearization controller. The user provides state space equations and output functions, which are symbolically represented and passed to inoutfeedbacklinearization to output the Lie derivatives and feedback linearization control law. A sample program TEST2 is also provided to demonstrate how a user would call the functions to analyze a specific system.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Feedback Linearization

Control
function df=LieDerivative(h,x)
% The LieDerivaive MATLAB function is used
% to find the jacobian vector of a given output
% h(x) : Is the output function
% x : The state vector
% df : The jacobian of h along x
if nargin<2 & nargin==0
error('not enough input argument');
end
df=[];
n=length(x);
for ii=1:n
xx=x(ii);
dff=diff(H,xx);
df=[df,dff];
end
df;
end
function [lhf lhg]=solvelieder(Lh,fx,g)
% The solvelieder MATLAB function is used to find
% the Lie derivatives of the functions f(x) and g(x)
% along the vector field h(x)
% Lh : The jacobian vector of h along x
% fx : The function f(x)
% g : The input function g(x)

LHg=[];
lhf=Lh*fx;
[n,b]=size(G);
for ii=1:b
Lgh=Lh*G(:,ii);
LHg=[LHg,Lgh];
end
lhg=LHg;
syms x1 x2 u % symbolic presentation
fx=[x2;-sin(x1)];
g=[0;1];
x=[x1 x2];H=x1;
LH=Lie_Derivative(H,x)
[lhf lhg]=solve_lie_der(LH,fx,g)

LH = [ 1, 0]
lhf = x2
lhg =0
clear all;clc
disp('--------------------------------------------------------------------');
TEST.m disp('The Nonlinear systems should ');
disp('be written in the following form ');
disp('State space equations x=f(x)+g(x)u');
disp('--------------------------------------------------------------------');
% The your system contains
% Input the extra parameters
par=input('Parameters ','s');
eval(sprintf('syms %s',par));
parameters=sprintf('%s',par)
%% Declare how many states and inputs
n=input('Number of states:=');
nin=input('Number of inputs:=');
x=sym(zeros(1,n));
u=sym(zeros(1,nin));
for j=1:n
eval(sprintf('syms x%d',j))
x(:,j)=sprintf('x%d',j);
end
for k=1:nin
eval(sprintf('syms u%d',k));
u(:,k)=sprintf('u%d',k);
end
% Enter the functions from the keyboard
f=input('The vector f(x):=','s');
g=input('The vector g(x):=','s');
H=input('The output variables:=','s');
%Represent all the functions
%f(x), g(x) and h(x) on a symbolic format
fx=str2sym(f);
gx=str2sym(g);
Hx=str2sym(H); %
% Use the inoutfeedbacklinearization.m
% programm to generate the desired functions
[Lhf Lhg]=inoutfeedbacklinearization(fx,gx,Hx,x)
function [Lhf Lhg]=inoutfeedbacklinearization(fx,g,h,x) if nargin <4
error('Not enough input argument');
% The function inoutfeedbacklinearization is used to find
end
the k=1;
% the feedbacklinearization control law for SISO and Lhg=[];Lhf=[];
MIMO nb=length(h);
% nonlinear systems using symbolic MATLAB library; while k<length(h)+1
% The user should provide the program with the following h1=h(k);
for i=1:nb+1
% inputs
% this Lie derivative function
% fx : The system function f(x) df=LieDerivative(h1,x);
% g : The system output function g(x) % solve for the g
% h(x) : The vector of outputs h(x)=[x1;x2, ;xn] [lhf lhg]=solvelieder(df,fx,g);
% x : The state vector x=[x1,x2, ,xn] [n b]=size(lhg);
% After having provided the program the necessary input for ii=1:n
% functions d=any(lhg(ii,:)==0);
end
% The program will output the following variables if d==1;
% Lhf : The lie derivative of h(x) along the function f(x) disp(['The relative degree of h',num2str(k)]),
% Lhg : The lie derivative of h(x) along the function g(x) disp(['equal:=',num2str(i)]);
% which is called the decoupling matrix break;
% u : The vector of inputs u=[u1;u2;...;un] else
% The control law will be given by the following formula h1=lhf;
end
% u= inv(Lhg)*(-Lhg+v) if i==nb+1 && d==0
disp(['The system dose not admit NFL']);
return;
end
end
Lhg=[Lhg;lhg];
Lhf=[Lhf;lhf];
k=k+1;
end
function df=LieDerivative(H,x) function [lhf lhg]=solvelieder(LH,fx,G)
% The LieDerivative MATLAB function is used % The solvelieder MATLAB function is used to find
% to find the jacobian vector of a given output % the lie derivatives of the functions f(x) and g(x)
% H(x) : Is the output function % along the vector field h(x)
% x : The state vector % LH : The jacobian vector of h along x
% df : The jacobian of h along x % fx : The function f(x)
if nargin<2 & nargin==0 % g : The input function g(x)
error('not enough input argument'); LHg=[];
end lhf=LH*fx;
df=[]; [n,b]=size(G);
n=length(x); for ii=1:b
for ii=1:n Lgh=LH*G(:,ii);
xx=x(ii); LHg=[LHg,Lgh];
dff=diff(H,xx); end
df=[df,dff]; lhg=LHg;
end end
df; end
end
The call program where the user has to provide the program with necessary input
functions is given as
TEST2.m nin=input('Number of inputs:=');
clear all;clc x=sym(zeros(1,n));
disp(‘-----------------------------------------------------------------');
u=sym(zeros(1,nin));
disp('The Nonlinear systems should be written in the
following form');
for j=1:n
disp(‘--Feedback Linearization Controller for a class of eval(sprintf('syms x%d',j))
Nonlinear systems—’); x(:,j)=sprintf('x%d',j);
disp(' State space equations x=f(x)+g(x)u end
'); for k=1:nin
disp(‘-------------------------------------------------------------------'); eval(sprintf('syms u%d',k));
%% Declare how many states and inputs
% The your system contains
u(:,k)=sprintf('u%d',k);
% Inout the extra parameters end
par=input('Parameters ','s'); %% Enter the functions from the keyboard
eval(sprintf('syms %s',par)); f=input('The vector f(x):=','s');
parameters=sprintf('%s',par) g=input('The vector g(x):=');
n=input('Number of states:='); Hc=input('The output variables:=','s');
%% Represent all the functions f(x), g(x) and h(x) on a
%% symbolic format
fx=str2sym(f);
%g=str2sym(g);
Hc=str2sym(Hc); %
%% Use the inoutfeedbacklinearization.m program to
generate
%% the desired functions
disp(['The feedbacklinearization controller Uc:']);
disp(['inv(Lhg)*(-Lhf+u)'])
[Lhf Lhg]=inoutfeedbacklinearization(fx,g,Hc,x)

You might also like