How to sequence signal inputs to state chart over sample intervals of 10?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am making a classic model of a fruit-packing plant. I am using two momentary buttons to start and stop the model in infinite sample time, which works as intended. However I want to create a test scenario where the signals change in intervals of 10 time samples, but I am not sure how to implement this. Here's what I mean:
- At sample time t = 0, start == 0, stop == 0. (Machine is OFF)
- Run simulation for 10 samples. (Machine is OFF)
- At t = 20, start == 1, stop == 0. (Machine starts)
- Run simulation for 10 samples. (Machine runs)
- At t = 30, start == 0, stop == 1. (Machine stops)
- Run simulation for 10 samples. (Machine is in standby)
- At t == 40, start == 1, stop == 0. (Machine restarts)
- Run simulation for 10 samples (Machine runs)
Any help is appreciated, hope my question is clear.
1 comentario
Respuestas (1)
Manikanta Aditya
el 28 de Abr. de 2023
Hi Nicolas
As per my understanding, you are interested to know how to create a test scenario where the signals change in intervals of 10-time samples.
Here is an example showing how you can do it:
% Set initial values
start = 0;
stop = 0;
% Main simulation loop
for t = 1:50 % iterate over 50 time steps
% Update start and stop signals based on current time
if t == 21
start = 1;
stop = 0;
elseif t == 31
start = 0;
stop = 1;
elseif t == 41
start = 1;
stop = 0;
end
% Run simulation for 1 time step
% Replace this with your actual simulation code
disp(['At time ' num2str(t) ': start = ' num2str(start) ', stop = ' num2str(stop)]);
end
I hope this resolves the issue you were facing.
0 comentarios
Ver también
Categorías
Más información sobre Complex Logic en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!