Index exceeds array dimensions when inputting time = 0

조회 수: 2 (최근 30일)
JACOB SHELDRAKE
JACOB SHELDRAKE 2020년 4월 30일
댓글: Ameer Hamza 2020년 5월 1일
I don't understand why I get this error, what does it mean that my array range is [1-1]?
Warning:Discontinuities detected within algebraic loop(s), may have trouble solving
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
Index exceeds array dimensions. Index value 0 exceeds valid range [1-1] of array u.
Error in 'DCDC/Pbase' (line 3)
y = u(1-exp(-t/0.001));
  댓글 수: 1
Sindar
Sindar 2020년 4월 30일
What is 'u'? Matlab seems to think it is a 1x1 array (with a valid range of indices from 1 to 1). So, if you pass [1-exp(-t/0.001) = 0] to it, you are trying to access the zeroth element, which does not exist

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 30일
From the description of the error message, it appears that you are trying to solve an ODE in Simulink. In that case, my guess is that you are trying to multiply u with the exponential term. Correct it like this
y = u*(1-exp(-t/0.001));
On the off-chance that 'u' is the unit step function, you can use heaviside function(): https://www.mathworks.com/help/releases/R2020a/symbolic/heaviside.html
  댓글 수: 2
JACOB SHELDRAKE
JACOB SHELDRAKE 2020년 5월 1일
All these years and it still gets me, thanks man.
Ameer Hamza
Ameer Hamza 2020년 5월 1일
I am glad to be of help.

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

추가 답변 (0개)

카테고리

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