Index exceeds array bounds.
조회 수: 1 (최근 30일)
이전 댓글 표시
clc; clear;
dt = 0.5;
Glucose = zeros(1,361);
Glucose(1,1) = 6000;
Glucose_Released = 110;
Glucose_Used = zeros(1,361);
Usage_Fraction = zeros(1,361);
t = 0:dt:180; % We need to generate a time vector for our plot
for k = 2:length(t)
Glucose_Used(k) = Glucose(k) * Usage_Fraction(k); % Based on Euler?sformula
Glucose(k-1) = Glucose(k) + [Glucose_Released(k) - Glucose_Used(k)]*dt;
end
Please help!!
댓글 수: 3
Adam Danz
2021년 4월 28일
Question edited to format code.
@Sudhaunsh Deshpande, looks like David hit the nail on the head. Let us know if you have any other questions.
채택된 답변
David Fletcher
2021년 4월 28일
You have defined Glucose_Released as a scaler value
Glucose_Released = 110;
You are then trying to index it, which will cause an error
Glucose_Released(k)
댓글 수: 6
Walter Roberson
2023년 5월 16일
You have
Glucose(i+1) = Glucose(i) + (G lucose_Released(i) Glucose_Used(i)) *dt
We can assume an accidental space,
Glucose(i+1) = Glucose(i) + (Glucose_Released(i) Glucose_Used(i)) *dt
but there needs to be something between Glucose_Released(i) and Glucose_Used(i)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!