Sunday, 15 June 2014

Matlab: link to variable, not variable value -



Matlab: link to variable, not variable value -

it has been hard utilize google, matlab documentation, i've spent few hours, , cannot larn how to

x = 1 y = x x = 10 y ans = 10

what happens instead is:

x = 1 y = x x = 10 y ans = 1

the value of x stored y. want dynamically update value of y equal x.

what operation utilize this?

thanks.m

matlab 99% pass-by-value environment, have demonstrated. 1% pass-by-reference handles, either handle graphics (not relevant here) or handle classes, pretty close want.

to utilize handle class describe, set next file phone call refvalue.

classdef refvalue < handle properties info = []; end end

this creates "handle" class, single property called "data".

now can try:

x = refvalue; x.data = 1; y = x; x.data = 10; disp(y.data) %displays 10.

matlab variables

No comments:

Post a Comment