Weekly to six monthly sum
    2 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    ARS
      
 il 18 Mag 2015
  
    
    
    
    
    Risposto: Walter Roberson
      
      
 il 18 Mag 2015
            Hi All
I have a matrix (named "X") with dimension 2196,7
Matlab (weekly) dates are in the first column and next 6 columns have prices
I wish to add (nansum) the first six month values and this becomes one observation in a new matrix "Y". Similarly, the sum of next six month values becomes the 2nd observation in matrix Y. And we do this till the last date (observation 2196).
Thanks for helping me in advance.
Regards
AHM.
0 Commenti
Risposta accettata
  Walter Roberson
      
      
 il 18 Mag 2015
           Y = reshape(nansum(reshape(X(:,2:7), [], 26, 6),2),[],6);
This will not have any date entries, but you did not define how you wanted that column handled. You could use
[X(1:26:end,1), Y]
if you wanted to select the first date of each group as indicating the time period.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Dates and Time in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!