Clear persistent variables of function on worker

1 Ansicht (letzte 30 Tage)
I need to clear the persistent variables of a function on all workers after having called it from a parallelized statement.
parfor n = 1 : N
persistentFunction()
end
spmd
clear persistentFunction
end
The above will not work because clear cannot be called from an spmd statement.
How can I clear persistentFunction ?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Mai 2023
parfevalOnAll(@() clear('persistentFunction'), 0)

Weitere Antworten (1)

Edric Ellis
Edric Ellis am 9 Mai 2023
Whenever you issue a clear command at the client, the same clear command is issued on the workers. So you can simply do
clear persistentFunction

Kategorien

Mehr zu MATLAB Parallel Server finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by