Monday, 15 February 2010

MatLab: identical function gets two different results -



MatLab: identical function gets two different results -

i see next behavior in 2013a , 2014a on windows computers:

someone sends me .mat file. in file, function fi(th, beta) defined. on command line phone call fi 2 values (actually beta matrix). then, click "edit value" fi , don't alter anything. then, when phone call fi(th, beta) 1 time again different value.

how can be? how can tell "correct" value?

the reason behind issue when clicking edit value on function handle, gets updated. in function, d used, variable during creation of function handle. suppose d has value, fi utilize new value after pressing edit value. allow me give example:

>> k = 2; >> f = @(x)k*x; >> f(4) ans = 8 >> k = 4; >> f(4) ans = 8

in example, k changed after f defined. however, f have original definition. when utilize edit value , don't alter anything, nevertheless utilize new value of k.

>> f % show function has not changed f = @(x)k*x >> f(4) ans = 16

i hope clearifies problem.

your question regarding right value depends on values , function handles used within function handle.

matlab function mat

No comments:

Post a Comment