how to set x axis into hours

I
ishitaisha6840 · Sep 2, 2020 · 1.9K views
Question
i have problem . how to i set the x axis into hour. i have 10080 data and each one represents one minute of data. i want to represents x axis with 24 hour, how can I make like that
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Sep 9, 2026

 

Displaying MATLAB Plot X-Axis in Hours (from Seconds)

When MATLAB plot X-axis values are in seconds and you want them displayed as hours, there are two common approaches:

1. Convert seconds to hours directly

If your time vector is stored in seconds, divide the vector by 3600 before plotting:

t = out.simlog.time;      % time in seconds
t_hours = t/3600;

plot(t_hours, data)
xlabel('Time (hours)')
Example: 7200 seconds = 2 hours.

2. Keep time in seconds but display the X-axis as hours

If you prefer not to modify your underlying data array, re-label the axis tick marks:

plot(t, data)
xt = xticks;
xticklabels(string(xt/3600))

xlabel('Time (hours)')

Plotting Simulink Results

For your typical out.simlog data structure:

t = out.simlog.time;
data = out.simlog.signals.values;

t_hours = t/3600;

plot(t_hours, data)
xlabel('Time (hours)')
ylabel('Value')
grid on
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!