Change value of parameters in simulink over time

18 次查看(过去 30 天)
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 个评论
Sam Chak
Sam Chak 2023-7-9
Try modeling the nonlinear system using @Deep's approach (MATLAB function block) based on the proposed mathematical model in my Answer.

请先登录,再进行评论。

回答(2 个)

Deep
Deep 2023-7-9
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 2023-7-9
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

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by