Time vector
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have 1000 data points and know that they were opbtained with 1Hz sampling. I also have begining time: Begining time = 12:00:00
How would I make a time vector? such that I can plot the data vs time and able to pick out a datapoint and know it's coorespoinding time.
Thank you!
0 comentarios
Respuestas (3)
Alex
el 31 de Oct. de 2011
Do you want the answer in hh::mm::ss format?
sample_index = (selected sample index);
%elapsed time in seconds
elapsed_time = sample_index*(1/frequency);
%hoping you have start time in seconds and not in a string
time_at_sample = elapsed_time + start_time;
tot_seconds = time_at_sample
%convert to str
hour = fix(tot_seconds / sec_in_hour);
tot_seconds = mod(tot_seconds, sec_in_hour);
min = fix(tot_seconds / sec_in_min);
sec = mod(tot_seconds, sec_in_min);
time_str = sprintf('%i%i%i', hour, min, sec);
0 comentarios
the cyclist
el 31 de Oct. de 2011
Here's one way:
basetime = [2011 01 01 12 0 0]; % Arbitrary date, starting at noon
basetimeVec = repmat(basetime,[1000 1]);
basetimeVec(:,6) = (0:999)'; % Add one second at a time (because 1 Hz rate)
timevec = datenum(basetimeVec); % MATLAB datenum format
datestr(timevec); % String with the time
0 comentarios
Fangjun Jiang
el 31 de Oct. de 2011
StartTime=datenum(2011,10,31,12,00,00);
OneSecond=1/3600/24;
TimeVector=StartTime+OneSecond*(0:1000);
datestr(TimeVector)
0 comentarios
Ver también
Categorías
Más información sobre Logical 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!