필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Why in the for cycle the values of the first row of the matrix y(i,j) don't exist?

조회 수: 1 (최근 30일)
AlexDp
AlexDp 2019년 9월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi all,
i'm trying to understand why the first row of the matrix "y(i,j) " isn't considered in my expression "FUNCTIONALITY13". If i run the program, "FUNCTIONALITY13" takes only the values of the last row of "y(i,j)", that is "i=2" .
This is my matrix (as you can see in the code): y(i,j)=[3 5 9; 2 4 8]. FUNCTIONALITY13 takes only the values that corrispond to "state_sys(2,j)" and all the values "state_sys(1,j)" are not taken. Someone could tell me why? How can i do so that FUNCTIONALITY13 takes all values of the matrix "y(i,j)"?
TIMEFAILUREPUM5=[4 6 10];
for j=1:length(TIMEFAILUREPUM5)
for i=1:2
y(i,j)=TIMEFAILUREPUM5(1,j)-i;
if t==(TIMEFAILUREPUM5(1,j)) &&(state_sys(y(i,j))==9||...
state_sys(y(i,j))==10|| state_sys(y(i,j))==11||state_sys(y(i,j))==12)
FUNCTIONALITY13=max(0, FUN13(t-1)-1);
else
FUNCTIONALITY13=min(1,FUN13(t-1));
end
end
end
Thanks to who will help me.

답변 (1개)

Shubham Gupta
Shubham Gupta 2019년 9월 24일
I think FUNCTIONALITY13 is being updated after each i, so FUNCTIONALITY13 is not storing all the values as matrix.
You might wanna change the "if...else" loop by
if t==(TIMEFAILUREPUM5(1,j)) &&(state_sys(y(i,j))==9||...
state_sys(y(i,j))==10|| state_sys(y(i,j))==11||state_sys(y(i,j))==12)
FUNCTIONALITY13(i)=max(0, FUN13(t-1)-1);
else
FUNCTIONALITY13(i)=min(1,FUN13(t-1));
end
I hope it helps !

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by