Change value of parameters in simulink over time
조회 수: 6 (최근 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.
답변 (2개)
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.

댓글 수: 0
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])
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!