From: Jos on 22 Jan 2010 04:48 Hi, I call a Matlab function from a .bat-file. Since I run the program as a function, there are no variables in the base workspace and only in the (invisible) function workspace. But, at the end of the function, I use report generator to generate a report that uses variables from the base workspace. But as already mentioned, all the variables are only saved in the function workspace. My question now is: can I save the function workspace in the base workspace? I already see two options: - Make every used variable a global variable. The problem with this is that its very time consuming given the large number of variable I have. - Put all the program code in the report stylesheet. The problem with this is that you loose overview of the code, as in the report explorer, it is not displayed as nicely as in the Editor ... So, is there an easier way to save the function workspace in the base workspace than declaring everything global?
From: Jos (10584) on 22 Jan 2010 05:38 "Jos " <jappedaneels(a)mathworks.com> wrote in message <hjbs8l$1f1$1(a)fred.mathworks.com>... > Hi, > > I call a Matlab function from a .bat-file. Since I run the program as a function, there are no variables in the base workspace and only in the (invisible) function workspace. > > But, at the end of the function, I use report generator to generate a report that uses variables from the base workspace. But as already mentioned, all the variables are only saved in the function workspace. > My question now is: can I save the function workspace in the base workspace? > I already see two options: > - Make every used variable a global variable. The problem with this is that its very time consuming given the large number of variable I have. > - Put all the program code in the report stylesheet. The problem with this is that you loose overview of the code, as in the report explorer, it is not displayed as nicely as in the Editor ... > > So, is there an easier way to save the function workspace in the base workspace than declaring everything global? I have no experience with the report generator, but perhaps you could save the variables in your function, and load them in the base workspace using evalin? function myfun A = 1 ; B = 2 ; save myvar.mat evalin('base','load myvar.mat') % now A and B are in the base workspace % >> whos, myfun, whos -> A & B present hth Jos
From: Steven Lord on 22 Jan 2010 09:47 "Jos " <jappedaneels(a)mathworks.com> wrote in message news:hjbs8l$1f1$1(a)fred.mathworks.com... > Hi, > > I call a Matlab function from a .bat-file. Since I run the program as a > function, there are no variables in the base workspace and only in the > (invisible) function workspace. > > But, at the end of the function, I use report generator to generate a > report that uses variables from the base workspace. But as already > mentioned, all the variables are only saved in the function workspace. My > question now is: can I save the function workspace in the base workspace? There are several ways to do this; the one I would suggest would be to return those variables that you want to use to generate the report as outputs from your function. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: iris normalization source code for iris recognition Next: FUZZY C-MEANS CLUSTERING |