Hallo guys,
I have data vs time from 15:00:00 TO 10:00:00 next day.
I'm trying to plot data vs time but the problem, it starts from 00:00 not from 15:00 and make the rest = 0
check the figure
I want to start from 15 till 00:00 and continue from 00:00 till 05:00

4 commentaires

Andy
Andy le 10 Mar 2021
Without seeing the data file I cannot say for certain. Is the data in a Timeseries? I assume the time is just recorded as a HH:MM:SS. You need to include the DD-MM-YYYY part then it should plot correctly.
Seth Furman
Seth Furman le 11 Mar 2021
As @Andy mentioned it is difficult for us to understand the problem without seeing data. Please attach a MAT file with the data and provide the MATLAB commands used to generate the figure above.
amr ahmed
amr ahmed le 2 Sep 2021
in the excel file, i want to plot coloumns A and B which have time and data, the problem that its 24H formate and it started from a day to next day so that the chart is cumulative.
amr ahmed
amr ahmed le 2 Sep 2021
RSSI_Average_NODE1 = readtable('Full_Room_plot.xlsx','Range','B:B'); %load column of RSSI
Array_Average_NODE1= table2array(RSSI_Average_NODE1); %convert rssi values to array
TIME_NODE1 = readtable('Full_Room_plot.xlsx','Range','J:J');%load column of RSSI
Array_Time_NODE1 = table2array(TIME_NODE1);
Time_formate_NODE1 = days(Array_Time_NODE1); %converting step
figure
plot(Time_formate_NODE1,Array_Average_NODE1) %plotting time(X-axis) Vs RSSI_Average(Y-axis)
title('NODE1')
I used this code and unfortunately the chart is not correct

Connectez-vous pour commenter.

 Réponse acceptée

Star Strider
Star Strider le 2 Sep 2021

0 votes

Try this —
Info = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/727204/Full_Room_plot.xlsx');
Info.Properties.VariableNames = compose('%c','A'+(0:9));
Array_Average_NODE1 = Info.B;
Array_Time_NODE1 = Info.J;
% Time_formate_NODE1 = hour(Array_Time_NODE1);
Time_formate_NODE1_Shift = hour(dateshift(Array_Time_NODE1, 'start','hour',-22));
figure
plot(Time_formate_NODE1_Shift, Array_Average_NODE1)
grid
xlabel('Time (hours)')
ylabel('Room Data')
The dateshift function can shift the time values to (in this instance) start at a specific time, here subtracting 22 hours from the beginning so that value is now the beginning of the series (hour 0).
Experiment to get different results.
.

2 commentaires

amr ahmed
amr ahmed le 2 Sep 2021
it is much better but i need the time in formate HH:MM:SS, to get the whole signal values
Try this —
Info = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/727204/Full_Room_plot.xlsx');
Info.Properties.VariableNames = compose('%c','A'+(0:9));
Array_Average_NODE1 = Info.B;
Array_Time_NODE1 = Info.J;
% Time_formate_NODE1 = hour(Array_Time_NODE1);
Time_formate_NODE1_Shift = hour(dateshift(Array_Time_NODE1, 'start','hour',-hour(Array_Time_NODE1(1))));
figure
plot(Time_formate_NODE1_Shift, Array_Average_NODE1)
grid
xlabel('Time (hours)')
ylabel('Room Data')
xtickformat('%2d:00:00')
set(gca, 'XTickLabelRotation',30)
% xt = get(gca, 'XTick'); % Without 'xtickformat'
% set(gca, 'XtickLabel',compose('%02d:00:00',xt), 'XTickLabelRotation',30) % Without 'xtickformat'
The ‘Time_formate_NODE1_Shift’ vector are no longer datetime values, so this is the best outcome.
Make appropriate changes to get different results.
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Axes Appearance dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by