Clear Filters
Clear Filters

Iterative Learning Control (problem with Matlab code)

15 views (last 30 days)
I have the following linear plant:
y(t+1)= -0.7*y(t) - 0.12*y(t-1) + u(t)
y(0)=2
y(1)=2
In this system, u(t) is the input at time t, and y(t) is the output of the system at time t. The initial condition of the system also is represented with two simple equations.
I want to force the system to follow a square wave such as:
y_d(t)=2, 0<t<10
4, 11<t<20
2, 21<t<30
I know that the ILC algorithm works as follows but i can't figure out the script for Matlab:
1)consider y_d and the initial input (first iteration, k=0)
2)run the system with this input and keep the result (y_0)
3)compute the error as $latex e_0(t)=y_d(t)-y_0(t)
4)compute the next input using the previous result as: u_1(t)=u_0(t)+K_p*e_0(t+1)
use u_1(t) and jump to 2.
I have chosen K_p=0.5.

Answers (1)

Hekma Sekandari
Hekma Sekandari on 11 Dec 2018
clear all;
close all;
clc;
y_d = ones(100)*2; % define the reference signal
% a step signal y_d=2 for t=1 to 30 s
u = ones(100)*0; % define first trial input
% input for the first trial it could be uo=0 or u0=y_d
y = ones(100)*0; % define initial conditions
trials = 100 ; % define the trials
Kp = 0.5 ; % define the gain Kp
% iteration loop
for j = 1:trials % j is trials index
for k = 3:30 % k is time index, 30 s is the final time
y(j,1) = 2; %initial conditions inside the loop for every iteration
y(j,2) = 2;
y(j,k) = -0.7*y(j,k-1)-0.12*y(j,k-2)+u(j,k-1);
e(j,k) = y_d(j,k)-y(j,k); % you must take care the sizes of the 2 vectors, y
% and y_d in order to the difference of the two be feasible! The size of y
% must be [trials(lines),final time(columns)]
u(j+1,k-1) = u(j,k-1)+Kp*e(j,k);
end
end
% plot in the same graph the reference input and the output y for each
% trial
plot(y_d(1,:),'or','LineWidth',5) % plot the 1est line and all the columns of vector y_d
hold all % hold all, holds several plots in the same graph
for w=1:trials
plot(y(w,:),'LineWidth',2) % plot for all trials
hold on
end
figure(2)
for w=1:trials
plot(e(w,:),'LineWidth',2) % plot for all trials
hold on
end
  2 Comments
mazin alseadi
mazin alseadi on 3 Nov 2020
please I did this codes but I have this problem ! so could you kindly help me ?
Index exceeds matrix dimensions.
Error in ILC_internet (line 19)
e(j,k) = y_d(j,k)-y(j,k); % you must take care the sizes of the 2 vectors, y
Olushijibomi Gbolade
Olushijibomi Gbolade on 28 Jul 2021
Hello Hekma Sekandari,
Please I need to for a simple batch reaction
A + B =C (desired product)
C = D (undesired product
where the initial concentration of A, Cao =10, the initial concentration of B, Cbo=1.167, the initial concentration of C, Cco=0, volume of the reactor is 1, Temperature of the reactor is 50K
y=f(x0,u0)
I am working on my thesis which concentrated on comparing the effects of Iterative learning control and model predictive control on a simple batch reactor process.
I would appreciate any help I can get.
Thanks

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!