How to add variables created in function to workspace?
15 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
Oleg Komarov
2011-7-8
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!