How to call global function?

3 visualizaciones (últimos 30 días)
Pramit Biswas
Pramit Biswas el 15 de Jul. de 2013
I want to use all variables used in function workspace, in Base Workspace and vice-versa. That can be possible using script(with certain limit that we can't pass argument)
Is it possible to get all feature of script(mainly working with base workspace variable) in function(mainly argument passing)?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 15 de Jul. de 2013
You can use global function
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 16 de Jul. de 2013
In the workspace type
global x y z % x,y z are your variables
% do the same thing inside your functions
function b=fcn(a)
global x y z
Jan
Jan el 18 de Jul. de 2013
@Pramit: Please consider, that global variables are one of the most hated bad programming patterns, In growing programs they increase the complexity such that debugging can become impossible.
Passing input and output arguments would be much smarter. Why don't you want / aren't you able to pass arguments?

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by