How can I create a loop so that I can analyze 100 files at a time?
3 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!