need a time series
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
I need a time series with 1 sec interval.
the cell will contain 00:00:01
.
00:01:59
.
24:59:59
.
25:59:59
.
72:59:59
How to create this array?
thanks in advance
regards Moon
1 Kommentar
Akzeptierte Antwort
  José-Luis
      
 am 2 Nov. 2012
        
      Bearbeitet: José-Luis
      
 am 2 Nov. 2012
  
      totHours = 72;
totMin = 12;
totSec = 21;
totVals = totHours*60*60+totMin*60+totSec;
hour_vec = cell2mat(arrayfun (@(x) repmat(x,60*60,1),(0:totHours)','uniformoutput',false));
min_vec = repmat(cell2mat(arrayfun(@(x) repmat(x,60,1),(0:59)','uniformoutput',false)),totHours+1,1);
sec_vec = repmat((0:59)',(totHours+1)*60,1);
your_string = reshape(sprintf('%02u:%02u:%02u',[hour_vec(1:totVals) min_vec(1:totVals) sec_vec(1:totVals)]'),8,[])';
6 Kommentare
  José-Luis
      
 am 6 Nov. 2012
				
      Bearbeitet: José-Luis
      
 am 6 Nov. 2012
  
			An alternative is:
 numHH = 72;
 numMM = 12;
 numSS = 36;
 totSec = 72*60*60 + 12*60 + 36;
 secVals = 0:64:totSec; %your interval in seconds here
 SSVec = mod(secVals,60);
 MMVec = floor(mod(secVals,3600)/60);
 HHVec = floor(secVals/3600);
 your_string = reshape(sprintf('%02u:%02u:%02u',[HHVec; MMVec; SSVec]),8,[])';
I think this deserves another + vote. While I like to help, this is starting to feel like work. In the future, try asking a new question instead of repeatedly modifying your initial question.
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!