Change value of parameters in simulink over time

18 views (last 30 days)
I am simulating a complex system and have a trouble. However, I will explain my problems by similar case.
Assuming I have a following system:
with a1, a2, a4, a5 are functions depending on u, v. For example, a1 = u*v; a2 = u+v; a4 = u-v; a5 = u/v (in fact, they are more bulky).
I want to change values u, v in a certain domain over time, it leads to a1, a2, a3, a4 are changed values. But, I don't know how to do.
Please help me. Thank you.
  1 Comment
Sam Chak
Sam Chak on 9 Jul 2023
Try modeling the nonlinear system using @Deep's approach (MATLAB function block) based on the proposed mathematical model in my Answer.

Sign in to comment.

Answers (2)

Deep
Deep on 9 Jul 2023
You can use a 'clock' and model your u,v signals as functions of the simulation time. For modeling complex and bulky math functions, a 'MATLAB function' block can help you write big functions as MATLAB code.
You can double click on the MATLAB function blocks to edit your functions.

Sam Chak
Sam Chak on 9 Jul 2023
If the parameters in the transfer function vary over time, then it is a nonlinear system. Nonlinear systems need to be modeled in the equivalent continuous-time state differential equations. In your case, the system output is .
Equivalent state differential equations and system output:
.
Substituting the parameters for as the time-varying functions of auxiliary inputs and
.
Since the system input is given, then the overall model becomes
.
In Simulink, if you are using basic blocks, then the system needs to be expressed in the Integral form. In other words, you need to construct the integrands (right-hand side of the ODEs) and then feed them into the input ports of the Integrator blocks.
The outputs of the Integrator blocks are the states , and they can be fed back into the integrands.
Example:
The following example assumes that the parameters are constants. But I think that you should get the idea.
% Parameters
a1 = 7;
a2 = 5;
a4 = 3;
a5 = 2;
params = [a1 a2 a4 a5];
% Transfer function of the Plant
G = tf([a1 a2], [1 a4 a5])
G = 7 s + 5 ------------- s^2 + 3 s + 2 Continuous-time transfer function.
tspan = linspace(0, 6, 60001);
x0 = [0 0];
[t, x] = ode45(@(t, x) odefcn(t, x, params), tspan, x0);
% Solution Plot
subplot(2, 1, 1)
plot(t, x(:,1), 'color', 'r'), grid on, ylabel('Amplitude')
title('Time response of Output, y(t)')
subplot(2, 1, 2)
step(G), grid on
function xdot = odefcn(t, x, params)
xdot = zeros(2, 1);
a1 = params(1);
a2 = params(2);
a4 = params(3);
a5 = params(4);
w = heaviside(t); % step input
xdot(1) = x(2) + a1*w;
xdot(2) = - a5*x(1) - a4*x(2) + (a2 - (a1*a4))*w;
end

Categories

Find more on General Applications 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!