How to change the time from seconds to hours of a plot from Simulink
23 次查看(过去 30 天)
显示 更早的评论
Hi, my knowledge of Matlab is very limited. I have a two signals from Simulink that I want to plot on a Matlab script. I sent my signals to the workspace and they come out as a 1x1 double timeseries. I want to change the timebase of my graphs from seconds to hours, since I'm simulating for 650000 seconds. I just don't know how to modify the time from my plots. Could someone help please?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1355633/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1355638/image.png)
0 个评论
回答(2 个)
Gokul Nath S J
2023-4-17
Hi Pierre-François Neumann-Chayer,
Based on my understanding of your request, it seems that you have simulated a system and have sent the output signal to the MATLAB workspace. In order to plot the signal, you would like to convert the x-axis from seconds to hours.
To achieve this, you can use the "To Workspace" block in Simulink. Once the simulation is complete, the data stored in Timeseries format will be available in a variable named 'out' in the workspace. Using the dot notation, you can access the data and time instant of the signal.
x_data = out.simout.Data;
t_data = out.simout.Time;
Once you have accessed the time data using the dot notation as mentioned earlier, you can apply this conversion to the time values by dividing them by 3600. This will give you the time values in hours, which you can then use to plot the signal data accordingly.
plot(t_data/3600, x_data);
with regards,
Gokul Nath S J
0 个评论
Ameen Bassam
2025-1-20,21:43
Open the timeseries. Then, you will find on the right bottom corner "Uniform Time Vector", click on it. You can change "Time units" from seconds to hours and change the start time and end time and finally click Apply.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Logging 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!