How to call global function?

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)?

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 15 Juil 2013

0 votes

You can use global function

3 commentaires

Pramit Biswas
Pramit Biswas le 16 Juil 2013
thank you for reply
Can you explain how can i do that?
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 le 18 Juil 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by