how to put date and time (exple 02-17-2023 06:05:34) on the x axis of a 3D plot

1 view (last 30 days)
Hello,
If someone can help please do.
I have date & time in a column in excel. I ploted the data (3D). X axis has date and time numbers. I want instead the actual date and time to be displayed. Example: 02-17-2023 06:05:34 intead of 7.53456 10^5).
Thank you in advance.

Accepted Answer

Kevin Holly
Kevin Holly on 17 Feb 2023
Edited: Kevin Holly on 17 Feb 2023
m = ["Jan-03-2023 06:25:12" 34 65; "Jan-04-2023 02:45:33" 56 34; "Jan-05-2023 07:05:38" 45 234]
m = 3×3 string array
"Jan-03-2023 06:25:12" "34" "65" "Jan-04-2023 02:45:33" "56" "34" "Jan-05-2023 07:05:38" "45" "234"
t = array2table(m)
t = 3×3 table
m1 m2 m3 ______________________ ____ _____ "Jan-03-2023 06:25:12" "34" "65" "Jan-04-2023 02:45:33" "56" "34" "Jan-05-2023 07:05:38" "45" "234"
t.Properties.VariableNames = {'Time' 'numeric variable 1' 'numeric variable 2'}
t = 3×3 table
Time numeric variable 1 numeric variable 2 ______________________ __________________ __________________ "Jan-03-2023 06:25:12" "34" "65" "Jan-04-2023 02:45:33" "56" "34" "Jan-05-2023 07:05:38" "45" "234"
t.Time = datetime(t.Time,"Format","MMM-dd-uuuu HH:mm:ss")
t = 3×3 table
Time numeric variable 1 numeric variable 2 ____________________ __________________ __________________ Jan-03-2023 06:25:12 "34" "65" Jan-04-2023 02:45:33 "56" "34" Jan-05-2023 07:05:38 "45" "234"
t.Time
ans = 3×1 datetime array
Jan-03-2023 06:25:12 Jan-04-2023 02:45:33 Jan-05-2023 07:05:38
scatter3(t.Time,double(t.("numeric variable 1")),double(t.("numeric variable 2")))
Edit: Here is another example.
t2 = table;
t2.Time = ["Jan-03-2023 06:25:12"; "Jan-04-2023 02:45:33"; "Jan-05-2023 07:05:38"];
t2.Time = datetime(t2.Time,"Format","MMM-dd-uuuu HH:mm:ss")
t2 = 3×1 table
Time ____________________ Jan-03-2023 06:25:12 Jan-04-2023 02:45:33 Jan-05-2023 07:05:38
t2.x = [34; 56; 45];
t2.y = [65; 34; 234];
scatter3(t2.Time,t2.x,t2.y,'filled','r')
  2 Comments
Ali
Ali on 28 Feb 2023
Hello Kevin,
I managed to display date/time on the axis. After ploting I noticed that the colors (based on the Z levels) are not consistent when rotating the graph. For instance, at certain level -70dBm, the color shoul;d be orange. I can see that color when rotating the graph certain direction. When rotating the graph 180degrees the colors looks blue (blue supposed to be for low levels below -95dBm). I attached document to show both situation. I also attached excel book that has some data. The number of rows goes up to 1500.
as far as ploting function, I am using:
figure();
surf(x,y4.Time, data,'EdgeColor','none')
patch([x, nan], [y4.Time, nan], [data, nan], ...
'FaceColor','none', 'EdgeColor','interp')
Thank you in advance.
Ali

Sign in to comment.

More Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 17 Feb 2023
Use readtable while importing your data into matlab and plot - see this example:
Data= readtable('DATA_Ts.csv', 'Format','%s%{dd-MM-yy HH:mm}D%f%f%s');
plot(Data.Time_Day, Data.Total, 'r-', 'linewidth', 2)
grid on

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!