How to sequence signal inputs to state chart over sample intervals of 10?
1 回表示 (過去 30 日間)
古いコメントを表示
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1341614/image.png)
Any help is appreciated, hope my question is clear.
回答 (1 件)
Manikanta Aditya
2023 年 4 月 28 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!