MATLAB Answers

0

"the scope of variable spans multiple functions matlab"

Asked by Panos Raptis on 16 Mar 2019
Latest activity Edited by Stephen Cobeldick on 17 Mar 2019
Can somebody tell me what is this message in "blue" variable "the scope of variable spans multiple functions matlab" ??
is it a nested function??
i have this code in attached image

  1 Comment

Those variables are used in nested functions. Nested functions are an intuitive and convenient way to simplify passing data between workspaces. Note that powutil4's alignment is misleading: the default MATLAB code alignment indents nested functions, which makes it clear which functions in a file are nested and which are local:

Sign in to comment.

1 Answer

Answer by Stephan
on 16 Mar 2019
 Accepted Answer

Hi,
yes, it is due to the nested functions. It is one possible way to avoid global variables. There is nothing wrong with it. The documentation suggests this as a proper way instead of the usage of global variables. So no worry.
Best regards
Stephan

  6 Comments

Did you notice that you can accept and/or vote for useful answers? Feel free to do so on useful contributions.

Sign in to comment.