Is there any way to define a variable in main function and use it in all sub-function.
I've tried to declare variables as global
but it seems I should repeat it in all function again. I'm wonder what's the benefit of global variable at all!
use variable as global
:
main program
global x
syms x
subfunc1
subfunc2
...
and
subfunc1
global x
and
subfunc2
global x
(maybe this format remind us to have global variable in function but it was better to cause error if we use same name of variable in function same as Matlab keywords) I don't want to import the variable as all function argument and don't want to declare that variable in all function again and again. any help would be appreciated.