MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Franchesca
on 18 Apr 2014

I have managed to write a loop which imports all the files into matlab however, it has imported them all into one matrix and to open an excel file I go into the matrix and have to double click the cell to open another matrix with all my data within it. The code is shown below:

numfiles = 54; % number of excel files mydata=cell(numfiles,1); % defining size of mydata

for k = 7:numfiles % loop to import mutliple excel files

myfilename = sprintf('Trial %d', k); % define file name

mydata{k} = xlsread(myfilename); % import files into mydata

end

What I require is a loop which imports the excel files in one go into individual matices so that I can process the data.

It would be great if you can help.

*No products are associated with this question.*

Answer by Walter Roberson
on 18 Apr 2014

Accepted answer

http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F

http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

Franchesca
on 20 Apr 2014

Thank you for the answer, however it says:

You should save them to an array or cell array if you need to use them outside the loop, otherwise use them immediately inside the loop. How do I save them to an array or cell array?

Below the picture shows how they are saved in Matlab at the moment, however I can't seem to open individual cells when writing my code to process the data. So is there a way to save each file as an individual variable or is there a code which allows me to go into this variable below and open a cell to then process the data.

## 0 Comments