> For the complete documentation index, see [llms.txt](https://nelson-9.gitbook.io/nelson/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nelson-9.gitbook.io/nelson/markdown/en/parallel/afterall.md).

# afterAll

Run function after all functions finish running in the background.

## 📝 Syntax

* B = afterAll(F, fcn, n)

## 📥 Input argument

* F - Input Future object (scalar or array).
* fcn - Function handle: Function to run after all input futures.
* n - Number of output arguments.

## 📤 Output argument

* B - AfterAllFuture object.

## 📄 Description

B = afterAll(F, fcn, n) returns a AfterAllFuture objectB.

Functionfcn is automatically runned after all elements in the Future arrayF were finished.

If any of the elements in F encounters an error, the Error property of B contains an error.

## 💡 Example

```matlab
pool = backgroundPool()
fptrRand = str2func('rand')
fptrMax = str2func('@(r) max(r)')
fptrMin = str2func('@(r) min(r)')
for idx= 1:10
    f(idx) = parfeval(pool, fptrRand, 1, 1000, 1);
end
maxFuture = afterEach(f, fptrMax, 1);
minFuture = afterAll(maxFuture, fptrMin, 1);
fetchOutputs(minFuture)
fetchOutputs(maxFuture)
```

## 🔗 See also

[backgroundPool](/nelson/markdown/en/parallel/backgroundpool.md), [fetchOutputs](/nelson/markdown/en/parallel/fetchoutputs.md), [afterEach](/nelson/markdown/en/parallel/aftereach.md).

## 🕔 History

| Version | 📄 Description  |
| ------- | --------------- |
| 1.0.0   | initial version |
