How to add variables created in function to workspace?
조회 수: 5 (최근 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!