How many times a date appears in an array
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Max
 el 10 de Oct. de 2015
  
    
    
    
    
    Respondida: the cyclist
      
      
 el 10 de Oct. de 2015
            I am given
7 10 2001 16 2 15 5
7 10 2001 20 18 0 5
7 10 2001 24 10 5 14
7 10 2001 26 15 2 1
7 10 2001 27 13 2 9
31 3 2002 1 9 0 6
1 4 2002 4 19 10 3
2 4 2002 5 30 11 12
3 4 2002 14 17 6 8
3 4 2002 21 29 8 3
4 4 2002 25 6 5 6
5 4 2002 2 24 2 0
The first column is the date second column is the month and third the year. For example 7 10 2001 is the 7th of October 2001. What would I need to write to show how many dates appeared in between and including 31 3 2002 and 3 4 2002. So from 31 3 2002 and 3 4 2002 there are 5 total dates (both 31 3 2002 and the two times 3 4 2002 come up are both included) So I would like the answer to be 5. Thanks for the help.
0 comentarios
Respuesta aceptada
  the cyclist
      
      
 el 10 de Oct. de 2015
        Here's one way:
D = [
7  10  2001  16  2  15  5
7  10  2001  20  18  0  5
7  10  2001  24  10  5  14
7  10  2001  26  15  2  1
7  10  2001  27  13  2  9
31  3  2002  1  9  0  6
1  4  2002  4  19  10  3
2  4  2002  5  30  11  12
3  4  2002  14  17  6  8
3  4  2002  21  29  8  3
4  4  2002  25  6  5  6
5  4  2002  2  24  2  0
]
dateNumber = datenum(D(:,3),D(:,2),D(:,1))
dateRangeBegin = datenum(2002,3,31)
dateRangeEnd = datenum(2002,4,3) 
numberOfDatesInRange = sum(dateNumber>=dateRangeBegin & dateNumber<=dateRangeEnd);
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Dates and Time 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!