How to implement FIFO in MATLAB with continuous input
3 次查看(过去 30 天)
显示 更早的评论
How to implement FIFO in MATLAB with continuous input.I dont have any idea about what is the frequency and magnitude in my problem statement.
3 个评论
Walter Roberson
2025-3-11
FIFO stands for First In First Out, which is one of the major queuing strategies.
Sam Chak
2025-3-11
编辑:Sam Chak
2025-3-11
Thanks @Walter Roberson. What do frequency and magnitude mean in this FIFO queuing context? I can't find the keywords in the Wikipedia and GeeksforGeeks articles. Does continuous input refer to non-discrete events, something is not separated into distinct parts?
采纳的回答
Walter Roberson
2025-3-11
Outline:
Q = [];
while true
check whether data is present
if data is present
new_data = fetch data;
Q(end:end+numel(new_data)-1) = new_data;
end
if ~isempty(Q)
Head = Q(1);
Q = Q(2:end);
do something with Head
end
end
1 个评论
Walter Roberson
2025-3-11
The above is suitable for cases where the existence of new data can be probed, or data is sure to come in "soon".
The above is not suitable for cases where the only way to obtain data is to wait around an indefinite time for it to be ready.
The approach for the wait-around case depends upon whether the device supports callbacks triggered when data is fetched.
If the device does not support callbacks, then you are better off moving the fetching of the data into a thread, whether that be through a process pool or a background pool. I am feeling lazy so I will only describe using threads if it is something you turn out to actually need.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!