How to implement FIFO in MATLAB with continuous input

3 Ansichten (letzte 30 Tage)
shital
shital am 11 Mär. 2025
Bearbeitet: Sam Chak am 11 Mär. 2025
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 Kommentare
Walter Roberson
Walter Roberson am 11 Mär. 2025
FIFO stands for First In First Out, which is one of the major queuing strategies.
Sam Chak
Sam Chak am 11 Mär. 2025
Bearbeitet: Sam Chak am 11 Mär. 2025
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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Mär. 2025
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 Kommentar
Walter Roberson
Walter Roberson am 11 Mär. 2025
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by