MATLAB: Alternative for eval of dynamic variables

dynamic variablesefficiencyevalfunctionMATLABmeshgridvariablesxyz

Hello,
From what I understand from the online community is that the use of dynamic variables is not acceptable/accurate/buggy.
I have 11 meshgrids (xyz-grids; to make it easy e.g. A,B,…,K) laying next to each other. For each of these 11 grids I want to calculate changing volumes over the years using 17 datasets (= xyz-data through the years). (the meshgrids have different sizes, that's why I did not make an overall grid)
I already assigned the xyz-data to my grids with scatteredInterpolant, so right now I have 17 variables (98,00,…,17) containing the same xy-values but different z-values (through the years; in total 11×17=189 variables; e.g. A_98,A_00,…,A17,B_98,…,K_17).
Now I need to calculate the volumes (=(difference between z-value & reference level)*gridsize; e.g. 50×50 and ref level -20) for each dataset for each mesh grid (so 17×11 times); afterwards I'll compare the results to each other so no need to worry about that.
The reason I like to use dynamic variables is the fact that results can be interpreted (more?) easily and that I don't really understand the online solutions for this.
Is there an efficient way to make a function or adjust my method/grids/variables/names to calculate the volumes of at least all datasets of 1 meshgrid (so 17x times) or even a way this can be done for all meshgrids at once (so 17×11 times)? (In the past I wrote everything 11×17 times which was very inefficient/dangerous for mistakes)
Thanks in advance for reading this (& maybe even helping me)!

Best Answer

If you use a cell array you can store everything in a single array even if the size are different. Because you can index into the cell array you can use a simple for loop, removing any need to repeat your code.