|
"Danny " <dmccorm2@nd.edu> wrote in message <jsa5kb$ifg$1@newscl01ah.mathworks.com>...
> Hi, I'm currently implementing a MATLAB script into another program called Glyphworks, so this might not be the right place necessarily to ask this.
> Essentially this program takes 'x' tests and runs them in a row, collating the data at the end. However, with the implemented MATLAB script it clears the variables for each loop and the program averages the tests as part of the calculations, so they must be retained in the script. To retain my data I used eval
> eval(['Data_' num2str(i) '=Data;']);
>
> However, I am met with this error:
> MATLAB script failed with error: Error using glyphscript/process (line 38) Attempt to add "Data_1" to a static workspace. See <a href="matlab: helpview([docroot '/techdoc/matlab_prog/matlab_prog.map'],'adding_variables_dynamically')">MATLAB Programming, Restrictions on Assigning to Variables</a> for details.
>
> Any ideas on how to retain my tests as they come, there could be any number of tests, that's why I loop variables in eval and give them Data_i name? I can save it to a cell and then load it from a .mat, but I still want to be able to isolate the a variable number of tests from the cell as different variable names.
===================
I thought we established in your other recent thread that you shouldn't need to do this
http://www.mathworks.com/matlabcentral/newsreader/view_thread/321241
Why is it that you need your results stored in different variables?
In any case, the html link in the error message you got will explain that in certain MATLAB workspaces, like those of nested functions, you cannot create a variable non-explicitly, e.g. using EVAL.
It's bad regardless. Try running the function below to see just one reason why
function test
eval('fft=[4 5 6];')
out=fft(3),
end
The output that I get is the following, which is obviously wrong.
>> test
out =
3
|