a nonlinear system and its control input in simulink
Show older comments
hi guys the system is as follows ;

which k(a,h) is defined as follows ;

I generally implement its block - daigram in simulink as follows ; I'm not sure whether it's correct or not ; I need your help on defining the functions

Accepted Answer
More Answers (4)
Hi @controlEE
While I cannot evaluate the MATLAB code from the image, it seems that
in Equation (6) represents a definite integral. The integrand is integrated from h to
, and the resulting function
is plotted below. It exhibits a distinct bell-shaped curve, which is commonly utilized in Prescribed-Time Control algorithms.
Did you obtain the same result?
syms t
a = 0.1;
h = 2;
tau = 5/7;
Rh = (sin(pi*t/h))^2;
expr= exp(2*a*t)*Rh
Wc = int(expr, [h, 2*h])
Wc = double(Wc)
W = inv(Wc);
Kah = Rh*W*exp(-a*(h - 2*t));
fplot(Kah, [h, 2*h]), grid on, xlabel('t')
title({'$K_{a, h}(t)$'}, 'Interpreter', 'LaTeX', 'fontsize', 16)
28 Comments
Sam Chak
on 16 Mar 2024
Hi @controlEE
Apart from the bell-shaped function
and the unrecognized
function, I don't observe any other special mathematical functions that might require assistance. The function
appears to be a piecewise function, with the second sub-function is a sine-squared function. These elementary functions are supported within the Simulink math blocks.
If you search for 'sig' in Wolfram MathWorld, you won't find anything useful. The term was likely informally coined by non-mathematician researchers in the past, and some control practitioners adopted it for ease of reference.

controlEE
on 17 Mar 2024
Hi @controlEE
Thank you for the update. I have plotted the function you mentioned.
If
is indeed intended to represent the mathematician's signum function,
, then when the argument x is a negative real number, it would result in complex numbers due to the fractional exponent in the expression. It's important to note that
represents the nth root of
. Therefore, I believe the authors did not intend
to be mathematically interpreted as
. It should be defined somewhere in the paper, perhaps in a numbered or unnumbered equation.
to be mathematically interpreted as
. It should be defined somewhere in the paper, perhaps in a numbered or unnumbered equation.It is worth noting that in the field of control, it is not uncommon for some practitioners with a practical focus (or those lacking an extensive mathematical background) to uncritically adopt the approaches of others.
x = linspace(-1, 1, 20001);
tau = 5/7;
expn= 2*tau - 1 % exponent is a fraction 2143/5000
y = (sign(x)).^expn;
plot(x, y, 'linewidth', 2), grid on, ylim([0, 1.2])
xlabel('x'), ylabel('y')
title({'$\left[\mathrm{sign}(x)\right]^{2 \tau - 1}$'}, 'Interpreter', 'LaTeX', 'fontsize', 16)
Hi @controlEE
I would suggest simulating the nonlinear system in MATLAB initially, before implementing the design model in Simulink. This approach makes it relatively easier to run the simulation on the MATLAB online platform and identify any errors that may arise from your code. You can click on the indentation icon
to copy/paste the code into the grey field.
Below is an example written as a 4-line script, with a 'function' named 'nonlinearSystem()' placed at the end of the script (from Line 7 to Line 18).
where the control input u is given by

tspan = [0, 5]; % simulation time % Line 1
x0 = 1; % initial value % Line 2
[t, x] = ode45(@nonlinearSystem, tspan, x0); % Line 3
plot(t, x), grid on, xlabel t, ylabel x(t) % Line 4
% Line 5
%% Function that describes the Nonlinear System % Line 6
function dx = nonlinearSystem(t, x) % Line 7
% parameters % Line 8
a = 2; % Line 9
b = 3; % Line 10
c = 5; % Line 11
% Line 12
% control input % Line 13
u = - (c*x)/b; % Line 14
% Line 15
% differential equation % Line 16
dx = a*sin(x) + b*u; % Line 17
end % Line 18
Sam Chak
on 21 Mar 2024
The 1st-order system you mentioned doesn't appear to be more complex than what you have described within the MATLAB function block. When you are ready to proceed, I suggest posting the MATLAB code using the template provided in my Example. This will assist in streamlining the process and obtaining the desired outcome.

controlEE
on 21 Mar 2024
Sam Chak
on 21 Mar 2024
Hi @controlEE
It seems there is some confusion. My suggestion is to start by implementing the algorithm in MATLAB first, as shown in the second sample code below. If you achieve success with the MATLAB implementation, you can then copy the same code (from Line 7 to Line 16) into your Simulink model, and it should work accordingly.
However, if you encounter any issues or errors, feel free to investigate and share the error message here for further assistance. Take a moment to contemplate and determine what should be written in Line 9, which corresponds to the control input u.
tspan = [0, 5]; % simulation time % Line 1
x0 = 1; % initial value % Line 2
[t, x] = ode45(@nonlinearSystem, tspan, x0); % Line 3
plot(t, x), grid on, xlabel t, ylabel x(t) % Line 4
% Line 5
%% Function that describes the Nonlinear System % Line 6
function dx = nonlinearSystem(t, x) % Line 7
% control input % Line 8
u = (...); % Line 9
% Line 10
% disturbance % Line 11
d = 0.1*x; % Line 12
% Line 13
% differential equation % Line 14
dx = x^3 + (1 + x^2)*u + d; % Line 15
end % Line 16
controlEE
on 22 Mar 2024
Good effort with the starting code. Could you find and fix the missing bracket(s) in this line first (scroll up)? We will need to troubleshoot this step-by-step. I previously overlooked the time-delayed term
) Later on, we will need to switch from the ode45 solver to the dde solver.
u = 1/(1 + x^2)*((-a/2*(1-tau)-0.1))*x(t)+(-Kah/2(1-tau))*y*(abs(x(t-h)))^2(1-tau)-x^3)
By the way, you should break down the control signal u into multiple parts so that you can troubleshoot the issue. Additionally,
is computed as a constant and is not dynamically linked to the nonlinear system. Therefore, you can directly assign "Wc = 1.8269" to save computational effort.
Lastly, I addressed the expression "(sign(x)).^expn" in my previous comment. It's possible that you overlooked it. When x is greater than 0,
will always produce 1, and raising 1 to the power of 'expn' will always yield 1. That's why I mentioned that the authors didn't intend "sig(x)" to be "(sign(x)).^expn".
OP: for instance we are working with the term x and we have a term in control x(t) , are they both same because we want to write the abs(x(t-h))
Regarding
and
, they represent the same state of the nonlinear system. However,
specifically refers to the state that is delayed by 2 seconds. It's important to note that you cannot directly use the mathematical notation 'x(t - 2)' in the code because MATLAB will interpret it as accessing the element of the vector x based on its index location (at t - 2) in the vector.
To handle the time-delayed state
, you need to implement a special assignment. For now, you can assume temporarily that
is equal to
without any delay.
% – - – - – - – - – - – - – - – - – -
Update: I have included a colored graphic to assist you in coding the four main parts of the controller individually, using just four lines of code. Once you have completed these four parts, you can combine them in the fifth line to create the complete controller.

% – - – - – - – - – - – - – - – - – -
I have managed to get the code running using a simple Proportional Control scheme, without incorporating the Prescribed Time Control law. To implement the 'non-time-delayed' Prescribed Time Control law, please modify the code by replacing 'uu' with the corresponding expression from your Prescribed Time Control law.
tspan = [0, 5]; % simulation time
x0 = 1; % initial value
[t, x] = ode45(@nonlinearSystem, tspan, x0);
plot(t, x), grid on, xlabel t, ylabel x(t)
%% Function that describes the Nonlinear System
function dx = nonlinearSystem(t, x)
% control input
% syms t % unnecessary if directly assigning Wc
a = 0.1;
h = 2;
tau = 5/7;
Rh = (sin(pi*t/h))^2;
expr= exp(2*a*t)*Rh;
% Wc = int(expr, [h, 2*h])
Wc = 1.8269; % direct assignment but Kah is not used
W = inv(Wc);
Kah = Rh*W*exp(-a*(h - 2*t)); % not used in this run
expn= 2*tau -1 ;
y = (sign(x)).^expn; % not used in this run
k = 3; % larger value makes convergence faster
uu = - k*x; % proportional control (for testing purposes)
u = (uu - x^3)/(1 + x^2); % cancel out the destablizing nonlinearity x^3
% state-dependent disturbance
d = 0.1*x;
% differential equation
dx = x^3 + (1 + x^2)*u + d;
end
Sam Chak
on 24 Mar 2024
You've made good progress so far. Let's now shift our focus to getting the code to run smoothly without any error messages. I've highlighted the parts that need your attention in order to fix them.
By the way, I'm curious. Have you previously implemented any linear full state feedback control algorithms in your prior experience before diving into the realm of nonlinear control?

Hi @controlEE
By the way, what is the title of the paper? Have you attempted to search for the paper to check if the author who wrote the code has mathematically defined the "sig" function, such as
?
?Previously, you made a mistake by assuming that 'a/b*c' is equal to
. However, I have fixed that issue in the code. Nevertheless, the response is still unstable due to the incorrect computation of the 'sig' function. Once you fix that, the response should become stable, as demonstrated by the coding author in the paper.
Transitioning from linear control to nonlinear control can be quite challenging even for those studying for a PhD, if you are unfamiliar with various aspects such as:
- Mathematical notations (e.g., piecewise function in Rh and the 'non-recognized' sig function)
- Math operator precedence (+, −, ×, ÷, ^, parentheses),
- Elementary math functions (
,
,
,
,
,
,
,
, etc.) - Differential equations (ordinary vs. delay),
- Divide and Conquer strategy for coding.
Mastering these concepts is crucial for making the prescribed time control algorithm works.
tspan = [0, 5]; % simulation time
x0 = 1; % initial value
[t, x] = ode45(@nonlinearSystem, tspan, x0);
plot(t, x), grid on, xlabel t, ylabel x(t)
%% Function that describes the Nonlinear System
function dx = nonlinearSystem(t, x)
% parameters (minor divide-and-conquer)
a = 0.1;
h = 2;
tau = 5/7;
Rh = (sin(pi*t/h))^2; % Minor issue: incorrect math function
Wc = 1.8269;
W = inv(Wc);
Kah = Rh*W*exp(-a*(h - 2*t));
expn= 2*tau -1 ;
%% DIVIDE: Four main parts of the controller
den = 2*(1 - tau); % denominator
p1 = (-a/den - 0.1)*x; % part 1
p2 = Kah/den; % part 2
p3 = (sign(x))^expn; % part 3 (MAJOR issue: incorrect math function)
p4 = abs(x)^den; % part 4 (assume no time-delay in x)
%% and CONQUER: Control signal
uu = p1 - p2*p3*p4; % dxdt = uu + d
u = (uu - x^3)/(1 + x^2); % control container
% state-dependent disturbance
d = 0.1*x;
% d = 0.1*exp(-t)*x;
% differential equation
dx = x^3 + (1 + x^2)*u + d;
end
Sam Chak
on 31 Mar 2024
@controlEE, Thank you for sharing the article. To find all instances of characters with "sig" in the PDF, you can utilize the "SEARCH" function. Once you have located them, you can proceed with working on the code.

Sam Chak
on 1 Apr 2024
Could you please share the updated Divide-n-Conquer code that addresses the bullet issues #1 and #2 mentioned in my previous comment? This will enable me to troubleshoot and identify any potential errors that occurred on your side and your team members.
If you are encountering difficulties with the Divide-n-Conquer code, let's divide the simulation problem into two sub-problems for the time being. [Ignore this if you already know how to proceed]
Task #1: Plot the piecewise function
.
Task #2: Plot the sigmoidal function
.
.This approach will allow your team member to address each task separately and ensure the accuracy of the plotted functions in part 2 (p2) and part 3 (p3) of the Divide-n-Conquer code.
Could you please include the time vector variable 't' in the code? It is necessary for the function
. Additionally, you can click the 'Play' button
on the MATLAB Answers forum to execute the code. This will help you identify any missing elements in the code when it throws error messages in red. In fact, it's also the method I use to troubleshoot your code.
If you are unfamiliar with the plot function, I suggest referring to the examples provided in this link. None of the examples utilize a for-loop approach.
It's important to note that this plotting code is separate from the Divide-n-Conquer code and is not directly related to it. You need to see what the piecewise function
looks looks like before inserting the code in
. Refer to the PDF, not the coded formula in the my Answer.
Hi @controlEE
I noticed that you made some revisions to your comment by adding additional code. However, when I clicked the Play button
to run the simulation, it seemed to complicate the whole matter.
Here is an example of how I plot a continuous-time W-shaped function
over the range of
. This will give you an idea of how I approach plotting in a simpler manner.
over the range of However, do remember that
is NOT a continuous-time function but a piecewise function.
%% Define the W-shaped function
tStart = -2;
tFinal = 2;
numpts = (tFinal - tStart)*1000 + 1; % number of data points
t = linspace(tStart, tFinal, numpts); % time vector
W = (cos(pi/2*t)).^2; % W-shaped function of time
%% Plot the graph
plot(t, W), grid on, ylim([-0.5, 1.5]) % requires inputs from t and W vectors
xlabel('t'), ylabel('W(t)')
title('W-shaped function')
controlEE
on 2 Apr 2024
Hi @controlEE
The error message "Unrecognized function or variable 'Kah'" indicates that the 'Kah' variable cannot be found in the for-loop script, which is responsible for computing the control signal u(i). In simpler terms, the algorithm is unable to locate the necessary information it needs to perform the calculations. To resolve this, you need to ensure that the required input is provided to the algorithm in the correct format.
I have made some modifications to the for-loop section based on your coded functions for 'Rh', so that the control signal u can be plotted. However, please note that the
function in the code is NOT a piecewise function, which causes the control signal u to oscillate within the time frame of
. During this period,
should not produce any output.
OP's question: Do you have any idea how to plot u signal in Divided code not using a loop?
If you don't wish to use the for-loop approach, then directly use the Vectorization method.
function dx = odefun(t, x)
u = - 2*x;
dx = sin(x) + u;
end
[t, x] = ode45(@odefun, [0 10], 1);
ut = - 2*x; % <-- vectorize the control algorithm
plot(t, x, '-o', t, ut, '-o'), grid on, legend('x(t)', 'u(t)')
If you define
solely as a continuous-time function, it would appear as displayed in Figures 1 and 2.
h = 2;
Rh = @(t) (sin(pi*t/h)).^2;
%% Plot over time range 2 < t < 4 ... (h < t < 2*h)
t = linspace(2, 4, 2001);
plot(t, Rh(t)), grid on, ylim([-0.5, 1.5])
xlabel('t'), ylabel('R_{h}'), title('Fig.1: R_{h} defined for 2 < t < 4')
%% Plot over time range from 0 to 6
t = linspace(0, 6, 6001);
plot(t, Rh(t)), grid on, ylim([-0.5, 1.5])
xlabel('t'), ylabel('R_{h}'), title('Fig.2: R_{h} plotted over 0 < t < 6')
Piecewise function 
However, I have been trying to emphasize that the true
is actually a piecewise function, as defined in the PDF. This needs to be addressed before moving forward, as what you have implemented in the ODE solver may not qualify as Prescribed-Time Control.

%% Plot True Rh according to the definition in the PDF
t1 = linspace(0, 2, 2001);
t2 = linspace(2, 4, 2001);
Rh1 = zeros(1, numel(t1)); % time interval t1 vector is used
Rh2 = (sin(pi*t2/h)).^2; % time interval t2 vector is used
plot(t1, Rh1, 'color', '#265EF5'), hold on
plot(t2, Rh2, 'color', '#265EF5'), hold off, grid on, ylim([-0.5, 1.5])
xline(2, '--');
text(0.7, 1.25, 'Interval 1')
text(2.7, 1.25, 'Interval 2')
xlabel('t'), ylabel('R_{h}'), title('Fig.3: True R_{h} defined according to PDF')
By the way, the straight-line triangle graph shown is definitely not representative of
. You should be able to recognize that something is amiss, as
contains purely sinusoidal functions, resulting in a curvaceous graph.

3 Comments
Sam Chak
on 5 Apr 2024
Hi @controlEE
You're welcome! I simply provided the essential guidance for you to gain insight into how mathematical functions behave across a function's domain. This understanding is crucial for studying dynamics and control. Merely observing the math notations of equations won't facilitate learning as it cannot be taught.
If you have these 3 items checked, you'll be prepared to proceed with solving the delay differential equation:
- Is the 'Rh' function correctly coded? ✔️

- Is the 'sig' function correctly coded? ✔️

- Check if the ode45 solver generates a result that closely resembles the one depicted in Figure 3 of the article. ✔️

Hi @controlEE
Great job on your progress shown in the comment. Now, I'd like to share my piecewise function formula with you:

Update: The article also discusses the piecewise function for the time interval
in Definition 1. Although the system remains stable, it is important to note that the settling time is significantly longer than the prescribed-time control performance, which is indicated as 3.4 seconds.
If you find the piecewise formula and the code provided helpful, I kindly request your consideration to vote 👍 for the solution presented in this answer. Your feedback and support are greatly appreciated.
%% Setting Unit Step function (to be used in constructing Rh)
old = sympref('HeavisideAtOrigin', 1);
%% Call ode45 solver
tspan = [0, 6]; % simulation time
x0 = 1; % initial value
[t, x] = ode45(@nonlinearSystem, tspan, x0);
%% Pass time vector t and solution x to nonlinearSystem to get Rh and u
[~, Rh, u] = nonlinearSystem(t, x);
%% Plot results
subplot(311)
plot(t, x, 'linewidth', 1.5, 'Color', [0.8500, 0.3250, 0.0980])
grid on, ylabel x(t), title('Response, x(t)')
subplot(312)
plot(t, Rh, 'linewidth', 1.5, 'Color', [0.9290, 0.6940, 0.1250])
grid on, ylabel Rh(t), title('Piecewise function, Rh')
subplot(313)
plot(t, u, 'linewidth', 1.5, 'Color', [0.4660, 0.6740, 0.1880])
grid on, ylabel u(t), title('Control action, u'), xlabel t
%% Nonlinear System
function [dx, Rh, u] = nonlinearSystem(t, x)
% parameters (minor divide-and-conquer)
a = 0.1;
h = 2;
tau = 5/7;
%% Piecewise function Rh using the piecewise formula
Rh1 = 0; % sub-function at interval 1
Rh2 = (sin(pi*t/h)).^2; % sub-function at interval 2
Rh3 = 0; % sub-function at interval 3
Rh = Rh1 + (Rh2 - Rh1).*heaviside(t - h) + (Rh3 - Rh2).*heaviside(t - 2*h);
Wc = 1.8269;
W = inv(Wc);
Kah = Rh.*W.*exp(-a*(h - 2*t));
expn= 2*tau - 1;
den = 2*(1 - tau); % denominator
%% DIVIDE: Four main parts of the controller
p1 = (-a/den - 0.1)*x; % part 1
p2 = Kah/den; % part 2
sig = sign(x).*(abs(x)).^expn; % part 3 renamed to 'sig'
p4 = abs(x).^den; % part 4
%% and CONQUER: Control signal
uu = p1 - p2.*sig.*p4; % dxdt = uu + d
u = (uu - x.^3)./(1 + x.^2); % control container
% state-dependent disturbance
d = 0.1*x;
% d = 0.1*exp(-t)*x;
% differential equation
dx = x.^3 + (1 + x.^2).*u + d;
end
45 Comments
Sam Chak
on 6 Apr 2024
Hi @controlEE
You're correct that the h-second-delayed state
is not considered in part 4. However, the equations in the code are 99% complete. The remaining step is to convert the ODE function into a DDE function so that you can utilize the dde23 solver. DDE requires past history so that the solver can access the solution for times before the initial integration point.
If the paper doesn't mention it, you can assume a constant delay that is the same as the initial value in the state. In other words, since
, you can assume that
.
To proceed, follow the steps outlined in the link below to code the DDE function. Once you've written the code, please post it, and I'll review it for any errors.
Sam Chak
on 7 Apr 2024
You did the 1% in DDE, but forgot to insert 99% of the code from the ODE function into the DDE function.
controlEE
on 7 Apr 2024
Sam Chak
on 7 Apr 2024
Just as shown in the DDE example. The entire differential equation shown in the image of your question above is DDE due to a single time delayed state.
There is NO separate partial ODE and partial DDE. Everything (99% + 1%) is grouped under a single DDE function.
controlEE
on 7 Apr 2024
Sam Chak
on 7 Apr 2024
Um... What kind of significant changes might be needed in the code and variables? Are these changes performed in accordance to the example shown in the "DDE with Constant Delays" article?

The derivatives
and
incorporate time-delayed states on the right-hand side, while
represents a regular ordinary differential equation. However, all three dynamic states are grouped together within the 'ddefun()' function. Interestingly, the code remains largely unchanged for the non-time-delayed state, resembling the ODE function.

Sam Chak
on 8 Apr 2024
Hi @controlEE
Referring to my previous comments, I have consistently emphasized the importance of placing the "entire code in the ode function" within the dde function. The example has two DDEs, but you only have a single 1st-order delayed differential equation
,where the ONLY time-delayed state
denoted by 'xlag1' lies in part 4 of u:

In the previous code, part 4 was implemented within the nonlinearSystem() function as:
p4 = abs(x).^den; % part 4
However, it should have been coded within the ddefun() function as:
p4 = abs(xlag1).^den; % part 4
This is the reason why I mentioned that 99% of the code remains unchanged.
Please prioritize this step, and I will assist you in identifying the necessary adjustments.
Sam Chak
on 9 Apr 2024
Hi @controlEE
While you did add the 99% of the code, you also unintentionally removed the crucial 1% that is necessary for solving delay differential equations using the dde23 solver.
In the example, the ddefun function requires a third parameter, Z, which represents the time-delayed state. Initially, you included this correctly in your comment, but it seems to have been accidentally omitted during the copy/paste process. when changing the function names from 'nonlinearSystem(t, x)' to 'ddefun(t, x)'. Moreover, the assignment of Z to the time-delayed state 'xlag1' has been overlooked.
Please rectify these issues and plot the response using the following syntax:
plot(sol.x, sol.y)

controlEE
on 9 Apr 2024
Indeed, similar to running the ode45 solver, the odefun(t, x) function requires the inclusion of the time parameter t and the state variable x in the input arguments. However, when adhering to the guidelines of the dde23 solver, the ddefun(t, x, z) function requires an additional input argument, specifically the time-delayed state variable z, as the third parameter.
Hi @controlEE
To troubleshoot the code, it is important to start by identifying the error message and understanding its meaning. To view the error message, simply click the run button, and the message will be displayed.
In this specific case, you have provided 'lags' as an input argument to the dde23 solver, but no variable named 'lags' has been assigned prior to this line. Do you happen to know what value should be assigned to 'lags'?
Additionally, unused variable 'x0' in the code should be removed, and the annotation "Call ode45 solver" should be revised to adhere to Good Engineering Programming Practice.

Update: Previously, you assigned the value of '2' to the variable 'lags'.

Hi @controlEE
Congratulations! You have successfully implemented the Prescribed-Time Control in the DDE, and the response closely matches the one depicted in the article. It seems that you prefer a more minimalist coding style, then you can utilize the following code instead.
sympref('HeavisideAtOrigin', 1);
sol = dde23(@ddefun, 2, @history, [0, 6]);
plot(sol.x, sol.y), grid on, xlabel t, ylabel x(t)
function [dx, u] = ddefun(t, x, z)
a = 0.1;
h = 2;
tau = 5/7;
Rh = ((sin(pi*t/h)).^2).*heaviside(t - h) - ((sin(pi*t/h)).^2).*heaviside(t - 2*h);
Kah = Rh.*(1/1.8269).*exp(-a*(h - 2*t));
sig = sign(x).*(abs(x)).^(2*tau - 1);
u = (((-a/(2*(1 - tau)) - 0.1)*x - (Kah/(2*(1 - tau))).*sig.*(abs(z).^(2*(1 - tau)))) - x.^3)./(1 + x.^2);
d = 0.1*exp(-t)*x; % 0.1*x
dx = x.^3 + (1 + x.^2).*u + d;
end
function s = history(t)
s = 1;
end
controlEE
on 21 Apr 2024
Torsten
on 21 Apr 2024
If you have no further constraints or expressions to minimize, you can choose phi = phi(t,x1,...,xn) to be any function with phi(t,0,...,0) = 0 for all t >=0. And ode45 will integrate system (22).
So either this is the solution or you did not state your problem properly.
Sam Chak
on 21 Apr 2024
Hi @controlEE
The 2nd problem also involves solving a time-delayed differential equation (DDE), but this time, the system in question is a third-order system, which adds complexity to the task. Therefore, I recommend posting it as a New Question so that other experts can contribute their insights and assistance.

To ensure effective communication and engagement, it would be helpful to clearly describe the DDE problem accompanied by relevant images. These images should include:
- The mathematical model of the system,
- The system's parameters,
- The time-delayed state-feedback control equation, u, and
- All design parameters in u.
It is worth noting that many people may lose interest in reading full articles (PDFs) to search for equations and information if they are unfamiliar with the symbols and terminology. Hence, including code snippets of your initial attempt using the dde23 solver would be beneficial.
You can mention that the inspiration for this approach came from a similar solution provided in this thread (don't forget to include the URL link). People are often more inclined to point out errors or suggest improvements in existing code rather than writing the code from scratch.
controlEE
on 24 Apr 2024
Sam Chak
on 24 Apr 2024
Hi @controlEE
I noticed a few key points regarding your recent post that may have contributed to it not receiving sufficient attention from the experts:
Key #1:
In your post, item 3 (the control equation for the second example) and the requested MATLAB code snippet are missing. Including these essential details could help generate more interest from the experts.
Key #2:
Based on the information provided in item 2, it appears relatively straightforward to code item 1. If you revise your post to include all the recommended materials (items 1–4), it will enable experts to run your code and provide valuable feedback, such as identifying errors or suggesting improvements.
Key #3: (Very important!)
Additionally, it's important to remember to work out your code in MATLAB before transitioning to Simulink. If your code functions correctly in MATLAB, it is highly likely to work in Simulink as well. Since most users are familiar with MATLAB but not necessarily Simulink, including the keyword "Simulink" in your title may cause MATLAB experts to skip your question. Similarly, Simulink experts may lose interest if your post does not include a block diagram or an .slx file.
Sam Chak
on 24 Apr 2024
If you observe the number of views on your post, you will notice that the count likely includes views from both @Torsten and myself.
By addressing the three key points ☝️ mentioned earlier and ensuring that you properly incorporate them into your post, you should be able to improve the situation and attract more attention 📈 from the experts. "Marketing skills" are also taught in Engineering Schools.

controlEE
on 25 Apr 2024
Hi @controlEE
Upon checking the keyword "Backstepping" on Wikipedia, I discovered that it is not a controller in itself but rather a recursive many-step control design procedure. This procedure can be quite tedious, which may explain why the authors did not provide the detailed workings in their paper. Since it involves multiple steps (in this case, three steps due to the system being third-order), it can consume a lot of space to present all the iterations in IEEE paper.
Unfortunately, my professor did not cover this specific topic. However, you have the option to implement other controllers that your professor taught you. If you are interested, I can provide you with a coding template below so you can design a state-feedback controller, via feedback linearization. Consider it a mini challenge to further develop your skills in controller design.
Also, please insert the provided code template in your new question and ensure that you revise the title to exclude the word "Simulink" if you would like to attract MATLAB experts to review your code.
q0 = -0.2;
Dq0 = -0.1;
I0 = 0.1;
tspan = [0, 20]; % set the simulation time
x0 = [q0; Dq0; I0]; % initial condition
[t, x] = ode45(@onelink, tspan, x0);
plot(t, x), grid on, xlabel('t'), title('Response')
%% One-link Manipulator
function [dx, u] = onelink(t, x)
% reference signals
q = (pi/2)*sin(t)*(1 - exp(- 0.1*t^2));
dq = exp(-0.1*t^2)*((-pi/2 + pi/2*exp(0.1*t^2))*cos(t) + 0.1*pi*t*sin(t));
Vp = 0.1*sin(50*pi*t);
% parameters
B = 1;
N = 1;
M = 1;
R = 1;
KB = 1;
L = 1;
% controller
u = 0; % to be designed by the User
% differential equations
dx(1,1) = x(2);
dx(2,1) = (N/M)*sin(q) - (N/M)*sin(x(1) + q) - (B/M)*x(2) + (1/M)*x(3);
dx(3,1) = - (R/L)*x(3) - (KB/L)*x(2) + (1/L)*u + (1/L)*Vp;
end
Sam Chak
on 8 May 2024
Hi @controlEE
You don't have to implement backstepping right away without gaining more experience in control design. If you're given a different 1st-order system, could you design a Periodic-Delayed Prescribed-Time Feedback Controller such that the system converges within 2 seconds?
My advice is to choose a simple system, gain experience by designing a stabilizing controller for it, and then revisit this example. Here's a simple 3rd-order system. Implement any stabilizing controller that you feel confident designing. The performance requirements are no overshoot, and the desired settling time is 1 second.
Sam Chak
on 9 May 2024
Hi @controlEE
Yes, designing the control law is indeed necessary. However, in this thread, I simply provided guidance on writing code when the control law 'u' is given. You haven't demonstrated the skills required for designing the prescribed-time control yet. Did I mention that this was my first time working on DDE in both MATLAB and Simulink? Despite that, I took on the challenge and successfully guided you through the original 1st-order control problem.
To be honest, I haven't acquired the skills in Periodic-Delayed Prescribed-Time Control design because I haven't identified any advantages (not to mention the complexities in implementation) compared to other more cost-effective controllers used for relatively simple problems. If you know of any advantages, please list them out for me.
Sam Chak
on 10 May 2024
Hi @controlEE
Before diving into the 3rd-order linear system,
I wanted to ask if you have any prior experience in designing a stabilizing feedback controller
for a 1st-order linear system?
controlEE
on 15 May 2024
Sam Chak
on 15 May 2024
@controlEE, Great! So, the one-link manipulator consists of three differential equations, and therefore, you have three control objectives to achieve.



However, for now, let's focus on stabilizing the state
in Eq.(1) as if it were the sole equation for the entire system. Additionally, consider the state
in Eq.(1) as a control input
that you are going to design. The goal is to design the control input so that
follows the desired reference signal
.
.At this stage, you can ignore both Eqs. (2) and (3). We will address Eq.(2) once you have successfully achieved Objective #1, that is
- To design a feedback control law for
in
such that
as
.
Sam Chak
on 24 May 2024
Hi @controlEE
I have reviewed the Simulink model (Fig. 1) and set the initial value to 1 to test if your designed controller can track the reference signal
. The result, as shown in Fig. 2, indicates that the system's output failed to track the reference signal
.
I understand that the Integral action in your PI controller can reduce or eliminate the steady-state error when properly tuned. However, in theory, in the absence of any unknown disturbances, such a single integrator system
does not require a PI controller. A Proportional-only controller would be sufficient to perfectly track the given reference signal
.
Can you redesign the Proportional-only controller based on the concept of driving the error
to zero? You should be working on the error dynamics
, and not the state dynamics
.
Please provide the relevant design equations so that we can review the design steps as you would publish in the Automatica Journal or IEEE Control Systems Letters. Your MATLAB code (preferred) or Simulink model should be based on the derived equations.
- - - - - - - - - - - - - - - - - - - -
Perhaps, start from here...
- - - - - - - - - - - - - - - - - - - -
Figure 1: Block diagram

Figure 2: Result

Figure 3: If
and
.
and 
Sam Chak
on 14 Jun 2024
Hi @controlEE
The code executes without producing error messages and generates the three intended plots. However, the diverging responses indicate that the controller may be incorrectly designed. It is evident that the error signals e1 and e2 remain unused within the code. While the reference signal q_d is employed in the control code, its time derivative dq_d is not.
Considering that this is a numerical simulation problem, I recommend posting a new question that includes the mathematical description of both the manipulator and controller. This will enable other MATLAB experts to examine the issue thoroughly.
With only the provided code, I am unable to conduct a comprehensive analysis as there is no reference math equations against which to verify the code.
Sam Chak
on 26 Jun 2024
Hi @controlEE
At the moment, your new post of the question (Example 2) has not yet appeared. I sincerely hope you will be able to share it soon, as this request has been postponed several times. Long thread with too many posts, lengthy codes and graphical figures makes loading the page relatively slow and uneasy to navigate.
I have reviewed the provided PDF. However, I was unable to locate your personalized step-by-step control design for the specific Example 2. The PDF in Section IV-A only outlines the general procedure for designing the proposed controller for an nth-order nonlinear system. This poses a technical challenge for me to thoroughly evaluate your code.
That said, one obvious issue I have observed is that you have implemented the controller using Eq. (26) without first designing Eq. (23). Since Example 2 is a 3rd-order system, Eq. (26) requires you to design
using Eq. (23). However, you have assigned a value of zero to this parameter 'x3_d', without any accompanying annotations in the code to explain the rationale behind this decision.


function dxdt = manipulator_dynamics(t, x, Z, K_a_h)
x1_d = 0;
x2_d = 0;
x3_d = 0;
...
z1 = x(1) - x1_d;
z2 = x(2) - x2_d;
z3 = x(3) - x3_d;
z3lag = Z(3,1) - x3_d;
% Control input
u = L * ((-a / (2 * (1 - tau))) * z3 + x3_d ...
+ R / L * x(3) + K_B / L * x(2) ...
- 5 * sign(z3) ...
- (K_a_h(t) / (2 * (1 - tau))) * (sig(z3 * (abs(z3lag)^(2 * (1 - tau)))))^(2 * tau - 1));
...
end
Sam Chak
on 27 Jun 2024
Hi @controlEE
Could you move your "Comment" to your New Question?
Elijah
on 19 Feb 2025
0 votes
what the sigma am i looking at
2 Comments
Hi @Elijah
It is not sigma, but rather an Absurd Sigmoidal function. The term 'Absurd' in this context is a compound word derived from 'Absolute' and 'Surd'. Essentially, it is defined as
.
. However, this notation is not commonly used in the field of mathematics and may cause confusion for some individuals, as is evident in your case. Typically, control theorists who are familiar with Super Twisting Control, Terminal Sliding Mode Control, and Prof. Han's Nonlinear ADRC (Active Disturbance Rejection Control) will recognize this notation.
Some control theorists, such as Prof. Leonid Fridman, use the notation
instead.
instead.x = linspace(-1, 1, 2001);
y = (abs(x).^(1/4)).*sign(x);
plot(x, y), grid on, xlabel('x'), ylabel('y')
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






































