clear all
close all
clc
tic
%---PID parameters---------------------------------------------------%
lamda(1)=20.08;lamda(2)=20.08;
lamda(3)=20.08;
%---fractional parameter alpha---%
lamda(4)=1.436;lamda(5)=0.564;
%---controlled system -------------------------------------------------%
[rstx, rstxd,rste2,rstu,rstT]=FOPID(lamda);
toc
%---trajectories of \psi and its reference \psi_d---%
figure
subplot(2,1,1);
plot(rstT,rstxd(:,1),'k-','linewidth',1.5)
hold on
plot(rstT,rstx(:,1),'b-.','linewidth',1.5) %reconstructed fault approximation error
grid on
h1=ylabel('\bf {Position} $x/m$');
h2=legend('$psi_d $','psi');
set(h1,'Interpreter','latex','fontsize',10,'FontName','Times New Roman','fontweight','bold')
set(h2,'Interpreter','latex','fontsize',10,'FontName','Times New Roman','fontweight','bold')
set(gca,'FontWeight','bold','fontsize',10,'FontName','Times New Roman')
% ylim([-1.5 1.5])
subplot(2,1,2);
plot(rstT,rste2(:,1),'r-.','linewidth',1.5);% x1-hatx1
grid on
h3=xlabel('Time(s)');
h1=ylabel('\bf {Tracking error}');
h2 = legend('$e$');%'$\hat x_{1}-x_{1d}$',' $x_{1}-x_{1d}$',
set(h1,'Interpreter','latex','fontsize',10,'FontName','Times New Roman','fontweight','bold')
set(h2,'Interpreter','latex','fontsize',10,'FontName','Times New Roman','fontweight','bold')
set(h3,'Interpreter','latex','fontsize',10,'FontName','Times New Roman','fontweight','bold')
set(gca,'FontWeight','bold','fontsize',10,'FontName','Times New Roman')
% ylim([-0.01 0.02])
%---the evolution of control input---%
figure
plot(rstT,rstu,'b-','linewidth',1.5)
grid on
% xlabel('time(s)');
h1=ylabel('$u_{psi}/N$');
% h2=legend('$Control \; signal$');
set(h1,'Interpreter','latex','fontsize',10)
set(h2,'Interpreter','latex','fontsize',10)
set(gca,'FontWeight','bold','fontsize',10,'FontName','Times New Roman')
% set(gca,'yTick',(-3:3:3));