How can I create a loop so that I can analyze 100 files at a time?

3 views (last 30 days)
I've looked everywhere and tried everything in my limited knowledge of MatLab. I wrote a code for two files that I want to be able to repeat for 200 files. Anyone know how I can loop the following so that it will read the excel file and analyze the data at the same time?
charge=xlsread('C:\Users\Documents\Battery\LiFePO4-KAU-3_Cha_1_003.xlsx');
discharge=xlsread('C:\Users\Documents\Battery\LiFePO4-KAU-3_Dis_1_004.xlsx');
timeC=charge(4:45,3);
currentC=charge(4:45,4);
voltageC=charge(4:45,8);
surfacetempC=charge(4:45,6);
timeD=discharge(4:6426,3);
currentD=discharge(4:6426,4);
voltageD=discharge(4:6426,8);
surfacetempD=discharge(4:6426,6);
Now instead of having one charge cycle and one discharge cycle, I have 100 of each.
I tried looping like I found on some examples where you replaced the number on the file name with a %f. I tried loop reading the files and then loop analyzing the files, but when it reads them it does cells within cells and I'm not very familiar with how those work and thus everything I tried to pull the data out of them failed.
Any and all help would be greatly appreciated. I am super stuck and don't know what to try next.
Thank you.

Accepted Answer

Image Analyst
Image Analyst on 6 Jan 2015
But for 200 files, you don't want to call xlsread() unless you are willing to wait a long time. You'd be best off using ActiveX, like in my attached demo.
  2 Comments
Ellen
Ellen on 6 Jan 2015
I can get all the files read pretty quickly with another method I tried. But I cannot seem to figure out how to analyze the data inside so that I can graph it. The problem I'm having is pulling out the data. The method used to read all the files created a cell within a cell system and I'm not sure how to pull the data out of that type of system.
Image Analyst
Image Analyst on 6 Jan 2015
You do know how, and you are doing it . You've called xlsread() and you're doing things like
surfacetempC=charge(4:45,6);
which is pulling data out of one array and putting it into another. So you've proven you know how.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!