Why is the built-in quantizer object in MATLAB 6.5 (R13) passed by reference and not by value?
2 ビュー (過去 30 日間)
古いコメントを表示
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.
採用された回答
MathWorks Support Team
2009 年 6 月 27 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cast and Quantize Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!