Sunday, 15 February 2015

calling variable that before created in function in matlab -



calling variable that before created in function in matlab -

i have function like:

[function y = testf (x, beta, z) y = sin (beta*z*x)./(x-z).^beta;]

the name of function ave, when phone call ave in matlab got error:

[input argument "beta" undefined error in ==> ave @ 2 y =sin (beta*z*x)./(x-z).^beta;]

what problem?

it may help if post source code , actual error matlab. question little unclear. however, seems problem scope. if create variable outside function, must passed function function see it.

for example:

a = 1 b = 2 myfunction(b): homecoming + b

will fail. function not know a is, though has been initialized somewhere. next will work:

a = 1 b = 2 myfunction(a, b): homecoming + b

edit: removed random c variable.

matlab

No comments:

Post a Comment