remove
Syntax
Description
Examples
Run a simulation on workers and retrieve the data storage of the job on a client. The data storage is a ValueStore object with key-value entries. Remove entries from this object as specified by their corresponding keys.
The following simulation finds the inverse of random matrices and stores the results in the ValueStore object.
type workerInvCodefunction workerInvCode(models)
% Get the ValueStore of the current job
store = getCurrentValueStore;
for i = 1:numel(models)
% Store simulation results in the ValueStore object
pause(1);
key = strcat("result_",num2str(i));
store(key) = inv(rand(models(i)));
end
end
Run a batch job on workers using the default cluster profile.
models = [4,8,32,20];
c = parcluster;
job = batch(c,@workerInvCode,0,{models});
wait(job);Retrieve the ValueStore object on the client. Show the keys of the object.
store = job.ValueStore; keys(store)
ans = 4×1 string
"result_1"
"result_2"
"result_3"
"result_4"
Remove multiple entries as specified by the keys "result_1" and "result_4" from the object.
remove(store,["result_1","result_4"]);
You can also remove an entry using the syntax store(key) = []. Remove the entry as specified by the key "result_3" from the object.
store("result_3") = [];Show the keys of the updated object.
keys(store)
ans = "result_2"
Run a simulation on a parallel pool of process workers and retrieve the file storage on a client. The file storage is a FileStore object with key-file entries. Remove entries from this object as specified by its corresponding keys.
The following simulation finds the average and standard deviation of random matrices and stores the results in the FileStore object.
type workerStatsCodefunction workerStatsCode(models)
% Get the FileStore of the current job
store = getCurrentFileStore;
for i = 1:numel(models)
% Compute the average and standard deviation of random matrices
A = rand(models(i));
M = mean(A);
S = std(A);
% Save simulation results in temporary files
sourceTempFile = strcat(tempname("C:\myTempFolder"),".mat");
save(sourceTempFile,"M","S");
% Copy files to FileStore object as key-file pairs
key = strcat("result_",num2str(i));
copyFileToStore(store,sourceTempFile,key);
end
end
Start a parallel pool of process workers.
pool = parpool('Processes');Starting parallel pool (parpool) using the 'Processes' profile ... Connected to the parallel pool (number of workers: 6).
Get the FileStore for this pool.
store = pool.FileStore;
Run the simulation on the pool.
models = [4,8,32,20]; future = parfeval(@workerStatsCode,0,models); wait(future);
Show the keys of the FileStore object.
keys(store)
ans = 4×1 string
"result_1"
"result_2"
"result_3"
"result_4"
Remove the key-file entries as specified by the keys "result_1" and "result_2" from the object. Show the keys of the updated object.
remove(store,["result_1","result_2"]); keys(store)
ans = 2×1 string
"result_3"
"result_4"
Input Arguments
Data or file storage shared by MATLAB clients and workers, specified as a ValueStore or
FileStore object.
Keys of entries to remove, specified as a character vector, string scalar, string array, or cell array of character vectors or strings.
Tips
For a
ValueStoreobject, you can also use the syntaxstore(key) = []to remove only one key-value entry as specified bykey.
Version History
Introduced in R2022a
See Also
ValueStore | FileStore | isKey | keys | put | get | copyFileToStore | copyFileFromStore
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)