How can I create a loop so that I can analyze 100 files at a time?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2015년 1월 6일
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
Image Analyst
2015년 1월 6일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!