Why is the built-in quantizer object in MATLAB 6.5 (R13) passed by reference and not by value?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
The following code demonstrates how the quantizer object is passed by reference.
function BugDemo()
q = quantizer
Change(q)
q
function Change(Q)
Q.format = [1 0]
The results of this code shows that changes made to the quantizer object in the "Change" function alter it within the "BugDemo" function.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
Although this is different behavior than that in previous versions, it is the expected behavior.
The following steps will simulate the R12 behavior within R13:
1. Create a copy of the object within 'BugDemo' before passing it:
function BugDemo()
q = quantizer
q2 = copyobj(q);
Change(q2)
q
function Change(Q)
Q.format = [1 0]
2. Create a copy of the object within 'Change' before altering it:
function BugDemo()
q = quantizer
Change(q)
q
function Change(Q)
Q2 = copyobj(Q);
Q2.format = [1 0]
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Cast and Quantize Data en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!