Does MATLAB copy large input parameters or does it operate on pointers?

14 vues (au cours des 30 derniers jours)
Christof Buss
Christof Buss le 27 Juil 2017
Modifié(e) : Adam le 27 Juil 2017
X is a large Array of matrices which is passed to a function f(X). Does MATLAB copy this Matrix or does the function f(X) read the original Matrix by means of pointers?

Réponse acceptée

Adam
Adam le 27 Juil 2017
Modifié(e) : Adam le 27 Juil 2017
Matlab takes a copy of a matrix only when you make a change to that matrix, so even though it does not use pass by reference (except for handle-derived classes) it will not take a copy of an array if you pass it to another function and use it for read-only purposes. The copy will happen when you make a change to the array in your function. i.e. essentially it uses copy-on-write semantics.

Plus de réponses (0)

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by