when does changing variable's value affects its structure address?
Ältere Kommentare anzeigen
Hey,
I was wondering why somtimes MatLab will change variable's structure address when the value of the variable is changed while in other time the address will remain the same. I am attaching 2 example cases below.
Thank you!

2 Kommentare
Walter Roberson
am 6 Jan. 2021
R2020b? or an earlier version?
Yakir Nisim
am 6 Jan. 2021
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 7 Jan. 2021
0 Stimmen
I think you might be running into https://www.mathworks.com/matlabcentral/answers/383188-mex-inplace-change-problems-r2015b-and-later?s_tid=srchtitle
When you do a literal initialization, a hidden copy of the value is taken for re-use if you reinitialize in exactly the same way. The hidden copy is a shared version, so the very first time you write to the variable, MATLAB needs to unshare the variable, which changes its address.
1 Kommentar
Yakir Nisim
am 13 Jan. 2021
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!