Hi all, Could you please help me to get the successive value from this code?
Here, I want to get the maximum value of from 2 values. e.g. when it is 5th iteration (i = 5) that time the maximum value should be 80 because when it was i = 3 that time we got the max value 60 from i = 1 and it is remained at i = 2.
More specifically what I want to get from this codes,
when it is i = 1
B = max(40,60) = 60
when i = 2
B = max (60,30) = 60
when i = 3
B = max (60,80) = 80
when i = 4
B = max(80,70) = 80
when i = 5
B = max(80,50) = 80
when i = 6
B = max(80,90) = 90
when i = 7
B = max(90,30) = 90
But in this code I am getting something different at i = 5 which is 70 but I need to get 80 at this time.
Thank you in advance.
A = [40, 60, 30, 80, 70, 50, 90, 30];for i = 1:length(A)-1 B = max(A(i:i+1)); C = A(i+1); if C/B < 0.7 x = C/10; else x = C/5; endend
Best Answer