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

3 ビュー (過去 30 日間)
Ali
Ali 2023 年 2 月 17 日
コメント済み: Ali 2023 年 2 月 28 日
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.

採用された回答

Kevin Holly
Kevin Holly 2023 年 2 月 17 日
編集済み: Kevin Holly 2023 年 2 月 17 日
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 件のコメント
Ali
Ali 2023 年 2 月 21 日
編集済み: Ali 2023 年 2 月 21 日
Thank you Kevin for answering my question.
Ali
Ali 2023 年 2 月 28 日
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

サインインしてコメントする。

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 2 月 17 日
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
  2 件のコメント
Ali
Ali 2023 年 2 月 21 日
編集済み: Ali 2023 年 2 月 21 日
Thank you Suloaymon for answering my question.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 2 月 21 日
編集済み: Sulaymon Eshkabilov 2023 年 2 月 28 日
Welcome Ali.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeBar Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by