# Huge data manipulation in Matlab

1. May 1, 2007

### Physics_wiz

I have about 5000 matrices which are all in excel. I need to put them all in Matlab so I can use them in programs. Every one of the 5000 matrices will be in its own excel sheet and they will all be saved in a folder. I don't mind reading them one by one in Matlab, but the thing I am having trouble with is manipulating the names of the matrices. For example, I want the first matrix to be called A1, the second to be called A2, third A3, etc... After all those are in Matlab, I want to do operations such as Ax(:,2)+A(x+1)(:,5) inside loops.

My main question is, can I somehow make a vector of just the names (i.e. names = [A1 A2 A3...A5000] and then use those in loops? Say I want to add every matrix to the one 5 steps after it like, B1 = A1+A6, B2 = A2+A7, etc... how can I use matrix names inside a loop?

Last edited: May 1, 2007
2. May 1, 2007

### LeBrad

It sounds to me like you want to use the 'eval' command. It allows you to assign things to and operate on variables names which are defined in terms of other variables.

For example, if I want to create 5 matrices which are called A1, A2, ..., A5, and have each matrix An be such that An = n*eye(n), I would write

Code (Text):

for n = 1:5
eval(['M' num2str(n) ' = n*eye(n)' ])
end

3. May 1, 2007

### Physics_wiz

Ahh I see. Thank you so much .

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook