It sounds like at some point in your code you created a bunch of dynamically named variables. This opens a can of worms and makes it more difficult to work with your data. Here's an explanation why dyanamic variable naming should be avoided at all cost.
Instead, those variables should be stored all together in an array. You can store them in a matrix or a multidimensional array (if the variables are all numeric or logical), or in a cell array or a table. The table and cell array can store your variable names at the top. Otherwise you can create a 2nd variable that stores the variable names so you can identify the rows, columns, etc.
Once you have reorganized your data, your indexing question will have a very simple solution.
Even if you don't have access to the code that produced those variable or you cannot recreate them, your best bet is to restrcuture them according to the description above before moving forward.
If you have any problems, let us know which format you chose and I'd be glad to help further.