Reputation: 4373
I have some data measured every 500 milliseconds, you can see my data in the following image:
Now what I would like to do, is to convert the X-axis into hours instead of milliseconds. How can I do this in Matlab? How can do this generally if I want for example minutes? days? etc.
Thank you for your help =)
Upvotes: 0
Views: 2085
Reputation: 21
If you have 100 data collected every 500 ms and you simply rescale the X axis to hours, you'll still get 100 data but as they had been collected every hour.
For example, suppose you have 3600 data collected every second.
data = rand(1,3600);
time_s = 1:3600;
Now, suppose you want to plot the data every minute. Without any processing, you could get every 60th sample in the data
array.
data_m = data(1:60:3600);
time_m = 1:60;
Doing this way, you'll get a consistent plot.
(I'd attach images but I lack reputation)
Upvotes: 2
Reputation: 13876
Well, that's pretty easy. Assume your vector is time_ms
, to get it in hours, you just need:
time_h = time_ms/(1000*3600);
Then instead of doing something like:
plot(time_ms,my_data)
Just do:
plot(time_h,my_data)
Upvotes: 4