Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
AlexDp
AlexDp am 23 Sep. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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.

Antworten (1)

Shubham Gupta
Shubham Gupta am 24 Sep. 2019
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 !

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by