How do I plot the control signal "u" ?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Sam Chak
le 31 Juil 2020
Modifié(e) : Sam Chak
le 31 Juil 2020
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;
0 commentaires
Voir également
Catégories
En savoir plus sur Switches and Breakers dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!