How to implement FIFO in MATLAB with continuous input

조회 수: 4 (최근 30일)
shital
shital 2025년 3월 11일
편집: Sam Chak 2025년 3월 11일
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
Walter Roberson 2025년 3월 11일
FIFO stands for First In First Out, which is one of the major queuing strategies.
Sam Chak
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
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
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개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by