Calculating cumulative for a series of numbers
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, I am trying to write a code to determine at which date the cumulative series of numbers reaches the value 6, but I have no idea where to start. Say for example I have a matrix of 2 columns: date= 1/07/2017 to 30/1/2017 col2= [1:30] The code should calculate the cumulative numbers in "col2" and show at which day the sum exceeds 6.
Any help would be highly appreciated. Many thanks
t1 = datetime(2017,07,1,8,0,0);
t2 = datetime(2017,07,31,8,0,0);
t = t1:t2
t_Col=t'
col2=col2=rand(31,1)
0 commentaires
Réponses (1)
KSSV
le 27 Août 2018
N = 100 ; % numebr of tiem stamps
t = 1:N ;
val = rand(1,N) ;
A = cumsum(val) ;
idx = A<=6 ; % cumulative sum less then 6
iwant = t(idx)
0 commentaires
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!