Good day, I need help in building a reference signal from an ISO Specification. I have tried "create signal app"; however, it does not help much.
1 view (last 30 days)
Show older comments
The signal is specified on an ISO 16750-2 page 9. I would like to track this signal using a PI, PID, ISMC, and DSMC to assess the controller performance. Please see the attached signal.
Your help will be highly appreciated.
0 Comments
Accepted Answer
Aquatris
on 29 Feb 2024
Something like this maybe
clc
tInit = 2; % initial Ub duration
tFin = 2; % final Ub duration
tr = 0.2;
t6 = 0.4;
t7 = 0.7;
t8 = 1;
tf = 40e-3;
Us = 8;
Ua = 9.5;
Ub = 12;
f = 9; % sine wave frequency [hz]
dt = 1e-3; % desired sampling time
t = 0:dt:(tInit+tr+t6+t7+t8+tf+tFin); % time vector
sig = NaN(size(t)); % initialize a sig variable
tt = 0; % misc variable to keep track of time while constructing the signal
% initial Ub
idx_tinit = find(t<tInit);
sig(idx_tinit) = Ub;
tt = tInit;
% tr section
idx_tr = find(t>=tt&t<tt+tr);
tt = tt+tr;
sig(idx_tr) = linspace(Ub,Us,length(idx_tr));
% t6 section
idx_t6 = find(t>=tt&t<tt+t6);
tt = tt+t6;
sig(idx_t6) = Us;
% t7 section
idx_t7 = find(t>=tt&t<tt+t7);
tt = tt+t7;
sig(idx_t7) = linspace(Us,Ua,length(idx_t7));
% t8 section
idx_t8 = find(t>=tt&t<tt+t8);
tt = tt+t8;
sig(idx_t8) = Ua-2*sin(2*pi*f*(t(idx_t8)-t(idx_t8(1))));
% tf section
idx_tf = find(t>=tt&t<tt+tf);
tt = tt+tf;
sig(idx_tf) = linspace(Ua,Ub,length(idx_tf));
% final Ub
idx_tfin = find(t>=tt&t<tt+tFin);
tt = tt+tFin;
sig(idx_tfin) = Ub;
plot(t,sig)
ylim([0 Ub+2])
xlabel('Time [sec]')
ylabel('Voltage [V]')
More Answers (0)
See Also
Categories
Find more on Multibody Modeling 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!