Number of peaks per interval
    1 visualización (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Priscilla
 el 2 de Ag. de 2020
  
    
    
    
    
    Comentada: Alan Stevens
      
      
 el 2 de Ag. de 2020
            how can I count the number of peaks in a given time interval such that if there was no peak detected the count is 0. 
This is what I have so far 
[time peakcount] =
     1     1
     2     2
     3     1
     4     2
     6     3
     8     2
I would like to have something like this NB: row 5 and 7. thanks
[time peakcount] =
     1     1
     2     2
     3     1
     4     2
     5     0
     6     3
     7     0
     8     2
0 comentarios
Respuesta aceptada
  Star Strider
      
      
 el 2 de Ag. de 2020
        
      Editada: Star Strider
      
      
 el 2 de Ag. de 2020
  
      One approach: 
t_pc = [ 1     1
         2     2
         3     1
         4     2
         6     3
         8     2];
t_pc2 = [min(t_pc):max(t_pc); zeros(1,numel(min(t_pc):max(t_pc)))].';
t_pc2(t_pc(:,1),2) = t_pc(:,2)
producing: 
t_pc2 =
     1     1
     2     2
     3     1
     4     2
     5     0
     6     3
     7     0
     8     2
A more efficient version: 
t_pc2 = (min(t_pc):max(t_pc)).';
t_pc2(t_pc(:,1),2) = t_pc(:,2)
.
0 comentarios
Más respuestas (1)
  Alan Stevens
      
      
 el 2 de Ag. de 2020
        How about:
newtime = 1:max(time);
newpeakcount(time) = peakcount;
2 comentarios
  Alan Stevens
      
      
 el 2 de Ag. de 2020
				No. It returns the counts with the zeros added, albeit transposed (but that's easily fixed);
newtime =
     1     2     3     4     5     6     7     8
newpeakcount =
     1     2     1     2     0     3     0     2
Ver también
Categorías
				Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


