Effacer les filtres
Effacer les filtres

How to add variables created in function to workspace?

27 vues (au cours des 30 derniers jours)
Sadanand
Sadanand le 8 Juil 2011
I have a function which reads variables from file. I want these variables to be added in base workspace. Currently after reading those variables, they are set to local variables in function. I want these variables to be added to workspace.

Réponses (2)

Oleg Komarov
Oleg Komarov le 8 Juil 2011
function [a,b] = myFun(X)
a = X/2;
b = X*2;
end
If you write your function in this way and then call it as
out = myFunc(10)
you will get the output in the workspace.

Chirag Gupta
Chirag Gupta le 8 Juil 2011
one option is assignin

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by