Filter löschen
Filter löschen

Index exceeds the number of array elements

1 Ansicht (letzte 30 Tage)
Tugce
Tugce am 30 Jul. 2024
Bearbeitet: Torsten am 30 Jul. 2024
Hi,
I got the error written below.
Index exceeds the number of array elements. Index must not exceed 2.
CHG_step = CHG_step(1:Inputs_RCC.CyclesxcRate); % Based on how many cycles x C-rate
Line 73 is written in bold black.
Tolerance_D = abs(Files.PreProcessedData{idx}.Current_A - Rated_Cap*Inputs_RCC.cRate_DCH) < AcceptedErrorCurrent;
RCC_Step_CHG = {}; % Find the unique steps for the Discharge rates
for i = 1:size(Inputs_RCC.cRates_CHG,1)
Tolerance_C = abs(Files.PreProcessedData{idx}.Current_A - Rated_Cap*cell2mat(Inputs_RCC.cRates_CHG(i))) < AcceptedErrorCurrent;
% Record the unique step if it's CC step, charge and the C-Rate is the one from the pulses
if i == 1
CHG_step = Files.PreProcessedData{idx}.FlagUniqueStep(Tolerance_C & contains(Files.PreProcessedData{idx}.Mode, "C_CC"));
CHG_step = unique(CHG_step);
CHG_step = CHG_step(CHG_step > Cap_Check_Steps(end)); % Take the steps after the cap check not to repeat them
CHG_step = CHG_step(1:Inputs_RCC.CyclesxcRate); % Based on how many cycles x C-rate
RCC_Step_CHG = [RCC_Step_CHG; num2cell(CHG_step)];
This is for test protocol of battery. So, the protocol is shown below:
"CHG step (Charge step), C-rates are C/, C/3, C/2, 1C and 2C."
Charge Steps 3 cycles at each C-rate
C/5 with C/20 cut-off
C/3 with C/20 cut-off
C/2 with C/20 cut-off
1C with C/20 cut-off
"2C
with C/20 cut-off"
Can someone please help me?

Antworten (1)

Torsten
Torsten am 30 Jul. 2024
Verschoben: Torsten am 30 Jul. 2024
My guess is that when you reach this line of your code
CHG_step = CHG_step(1:Inputs_RCC.CyclesxcRate); % Based on how many cycles x C-rate
CHG_step is an array of size (1x2). But the variable "Inputs_RCC.CyclesxcRate" is greater than 2. So you try to access elements of CHG_step that don't exist.
  2 Kommentare
Tugce
Tugce am 30 Jul. 2024
Thank you. Yes, you're right, but how can I fix or change it?
Torsten
Torsten am 30 Jul. 2024
Bearbeitet: Torsten am 30 Jul. 2024
Since you are the only person who knows what's going on in your code, you are also the only person who can find a proper solution for this array access error.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by