add two elements from diffrent matrices and store it into new matrix.

my code is like this and i got error:
Index exceeds array bounds.
Error in line 3
QtA(t)=max(0,QtA(t-1)+LAMtA(t)-OtA(t)-LtA(t));
i just want to do arithmatic operation of diffrent elemtents of diffrent matrices and want to store it into a matrix as element. please help me. I am new at matlab.
i have matrices as shown in fig.
VtA(t)=max(0,N1-LAMtA(t-1)-LAMtA(t)+OtA(t));
VtD(t)=max(0,N2-LAMtD(t-1)-LAMtD(t)+OtD(t));
QtA(t)=max(0,QtA(tp-1)+LAMtA(t)-OtA(t)-LtA(t));
QtD(t)=max(0,QtD(tp-1)+LAMtD(t)-OtD(t)-LtD(t));

 채택된 답변

VBBV
VBBV 2020년 12월 15일
편집: VBBV 2020년 12월 15일
QtA(t)=max(0,QtA(tp)+LAMtA(t)-OtA(t)-LtA(t-1));

댓글 수: 3

if you use QtA(tp-1) you are trying to access zerothe element in QtA, which is undefined.
VBBV
VBBV 2020년 12월 15일
편집: VBBV 2020년 12월 15일
Similarly LtA(t) are trying to access 2nd element which is not present, since t = 2
Thank you 🙂. I got it.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2020년 12월 15일

댓글:

2020년 12월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by