How do I plot the control signal "u" ?

조회 수: 6 (최근 30일)
Muhammad Azeem
Muhammad Azeem 2020년 7월 27일
편집: Sam Chak 2020년 7월 31일
Given a 2nd-order system:
x'' = u; subject to x(0)=1; x'(0)=0;
where "u" is a piecewise function given by
if |x| < 0.2, then u= - 0.5x' - x
if |x| > 0.2, then u= - 2.0x' - x
related matlab algorithm is
% calling ode45
t0 = 0 ;
tf = 20 ;
tspan = [t0 tf];
x0 = [1 0];
[t,x] = ode45(@(t,x) ode(t,x), tspan, x0);
figure(1)
plot(t, x(:,1), t, x(:,2))
% function file
function dx = ode(t,x)
dx = zeros(2,1);
dx(1) = x(2);
if abs(x(1)) < 0.2
u = - 0.5*x(2) - x(1);
else
u = - 2.0*x(2) - x(1);
end
dx(2) = u;
end
I want to plot “u“ the control signal, but I'm unable to plot this control signal "u". Anyone can help me please if you can. I already attach matlab code (Question.m) for better understanding.
Thank you.

답변 (1개)

Sam Chak
Sam Chak 2020년 7월 31일
편집: Sam Chak 2020년 7월 31일
One workaround to plot the piecewise control signal u is to introduce an additional state into the system, where is the actuator. Technically, the piecewise control signal can be approximated by the actuator, which can be modeled as a 1st-order system.
where τ determines how fast you want the actuator to approximate the control signal u in seconds. So, if you want to catch up with u in 0.01 sec, then you would want to select . Here are the changes that you need to apply to the codes:
x0 = [1; 0; 0];
dx = zeros(3, 1);
dx(2) = x(3);
dx(3) = (-x(3) + u)/tau;

카테고리

Help CenterFile Exchange에서 Switches and Breakers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by