advanced patterns when using 'eval' to create variables dynamically in MATLAB
I'm dealing with I'm dealing with I'm experiencing unexpected behavior when trying to create variables dynamically using the `eval` function in MATLAB. My goal is to generate a series of variable names based on an index in a loop, but I'm running into issues with accessing those variables later. Here's an example of what I've done: ```matlab for i = 1:5 eval(sprintf('data%d = rand(3);', i)); end ``` After running this loop, I expect to have variables `data1`, `data2`, `data3`, `data4`, and `data5` created, each containing a 3x3 random matrix. However, when I attempt to access `data3` later in the code, I receive the following behavior: ``` Undefined function or variable 'data3'. ``` I've checked my code and it seems that all variables should have been created without scenario. I've also tried using `clear` prior to the loop but it hasn't changed the outcome. I know using `eval` isn't always the best practice, but I need to generate variable names dynamically this way for my specific application. Is there a better method to accomplish this, or am I missing something with how `eval` works in this context? Any help would be appreciated! I'm working with Matlab in a Docker container on CentOS. Has anyone dealt with something similar? For context: I'm using Matlab on Debian. I'd love to hear your thoughts on this.