필터 지우기
필터 지우기

Index exceeds the number of array elements

조회 수: 1 (최근 30일)
Tugce
Tugce 2024년 7월 30일
편집: Torsten 2024년 7월 30일
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?

답변 (1개)

Torsten
Torsten 2024년 7월 30일
이동: Torsten 2024년 7월 30일
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
Tugce
Tugce 2024년 7월 30일
Thank you. Yes, you're right, but how can I fix or change it?
Torsten
Torsten 2024년 7월 30일
편집: Torsten 2024년 7월 30일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by