convert time from sample to second
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello .. i have a simulink program, the solver is a fixed step type (with sample time 0.001), when the program run, i have a result as shown in figure below (the time axis in sample not second) ,,, this 300 sample is almost equal 10 real seconds, how to convert the time axis to seconds instead of samples (by using plot command if possible) ?
1 commentaire
Image Analyst
le 28 Juin 2014
Original question (in case he edits it away like the others)
hello .. i have a simulink program, the solver is a fixed step type (with sample time 0.001), when the program run, i have a result as shown in figure below (the time axis in sample not second) ,,, this 300 sample is almost equal 10 real seconds, how to convert the time axis to seconds instead of samples (by using plot command if possible) ?
Réponses (2)
Azzi Abdelmalek
le 27 Juin 2014
te=0.001
xt=get(gca,'xtick')
set(gca,'xticklabel',arrayfun(@num2str,xt*te,'un',0))
4 commentaires
Daniel kiracofe
le 28 Juin 2014
Well, if the time step is 0.001s and you have 300 samples, then 300 * 0.001 = 0.3, which is not 10s. So either you don't really have 0.001s time step, or you don't really have 10s of data. But if you are really sure that 300 samples = 10s, then you could just use linspace:
time = linspace(0, 10, 300); plot(time, data);
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!