Trying to get certain values from an excel file
Show older comments
Hello I'm really new to matlab. I'm trying to get certain values from an excel file.
This is part of the excel table ( it has a lot more lines) but this a fragment of the table I'm looking for. The voltage is what i want

At the moment I'm trying to save into a variable the voltage from the excel table with different conditions for example in this one i figure would be something like while step_time == 10 & Cycle_index 16 get the voltage at this conditions.
This is part of the code i was trying to do:
V = xlsread('PRS1_42V_55C_SDP881V1_457845_070722.xlsx',2,'H1:H216000');
StepTime = xlsread('PRS1_42V_55C_SDP881V1_457845_070722.xlsx',2,'D1:D116000');
V2= V(CycleInd == 16); % I got all the values from the cycle index i want
Vu1 = V2(StepTime == 10) % I was trying to get the value when the step time is 10 but there's an error "The logical indices contain a true value outside of the array bounds."
Answers (1)
dpb
on 24 Aug 2022
Perfect place for a table -- keeps everything together with variable IDs and you have access to everything as you need it. I don't know why folks keep going back to xlsread unless it's because it's name begins with 'xls' and so it just gets found before anything else -- and the general documentation is ignored. Anyways, that aside,
tData=readtable('PRS1_42V_55C_SDP881V1_457845_070722.xlsx',''Sheet',2);
ix=(tData.CycleIndex==16)&tData.StepTime==10);
Now, do whatever with tData(ix,:)
You got an error before because the length of the second variable had been reduced over that of the first.
From the data we can see, it's possible there may be no identically==10 values of the times although I guess the error indicates at least one.
Categories
Find more on Data Import from MATLAB 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!