Main Content

Background and Parallel Processing

Run code in the background or at a specified time

MATLAB® includes functionality to set timers for program execution and to run code in the background.

Functions

expand all

timerSchedule execution of MATLAB commands
deleteDelete files or objects
isvalidDetermine valid handles
startStart timer
startatSchedule timer to fire at specified time
stopStop timer
timerfindFind timer objects
timerfindallFind all timer objects
waitBlock command prompt until timer stops running

Background Execution

parfevalRun function in background (Since R2021b)
parfevalOnAllRun function on all workers in background
backgroundPoolEnvironment for running code in the background (Since R2021b)

Futures

fetchOutputsRetrieve results from function running in the background
afterEachRun function after each function finishes running in the background
afterAllRun function after all functions finish running in the background
cancelStop function running in the background
cancelAllStop all functions running in the background (Since R2022a)
waitWait for futures to complete
fetchNextRetrieve next unread outputs from Future array
FutureFunction scheduled to run

Data Queues

sendSend data to DataQueue or PollableDataQueue
pollRetrieve data from PollableDataQueue
closeClose pollable data queue (Since R2025a)
afterEachRun function after data is received on DataQueue
parallel.pool.DataQueueSend and automatically process data
parallel.pool.PollableDataQueueSend and manually retrieve data
parallel.pool.ConstantCopy or create data only once on workers in parallel pool (Since R2021b)