MATLAB: X axis labeled with time only from 0 to 24

axisplot

Hi everyone, I'm running a code where i have to plot some characteristics of a GPS satellite during a period of time. The trouble is that this period of time is 6h, and if I make: plot(time,myvariable) then I could get times over 24h. I would like them to be 00.00, 01.00h… I can't solve it by: if(time>24), time=time-24 or similar because it would not respect the correct time flow of the system. Does anyone know how to solve it? thank you!!

Best Answer

I am not certain what you want to do.
See if this works:
time = 0:47; % Create Data

satellite = sin(2*pi*time/24) + 1; % Create Data
time_wrap = mod(time,24);
figure(1)
plot(time, satellite)
xt = get(gca, 'XTick');
set(gca, 'XTick',time(1:6:end), 'XTickLabel',time_wrap(1:6:end))