How to plot a line graph calling specific depths from a table.

4 ビュー (過去 30 日間)
Anna
Anna 2025 年 2 月 12 日
コメント済み: Voss 2025 年 2 月 12 日
I have a data set with differing depths and need to plot three lines (depths 5, 25, 50) on one graph. Aside from sorting the data by ascending or descening, how can I force the graph to plot only values associated with the specific depth? Below is an example of my data.

採用された回答

Voss
Voss 2025 年 2 月 12 日
T = table( ...
datetime(["28-Jan-2025";"29-Jan-2025";"30-Jan-2025";"30-Jan-2025";"30-Jan-2025";"31-Jan-2025";"31-Jan-2025";"31-Jan-2025";"03-Feb-2025";"03-Feb-2025";"03-Feb-2025"]), ...
[25;25;5;25;50;5;25;50;5;25;50], ...
[0.84;2.4;1.7;1.8;7.5;1.8;2;2.3;28.1;28;29.4], ...
'VariableNames',["Date","Depth","Turb"])
T = 11x3 table
Date Depth Turb ___________ _____ ____ 28-Jan-2025 25 0.84 29-Jan-2025 25 2.4 30-Jan-2025 5 1.7 30-Jan-2025 25 1.8 30-Jan-2025 50 7.5 31-Jan-2025 5 1.8 31-Jan-2025 25 2 31-Jan-2025 50 2.3 03-Feb-2025 5 28.1 03-Feb-2025 25 28 03-Feb-2025 50 29.4
figure
hold on
[G,GID] = findgroups(T.Depth);
splitapply(@(d,t)plot(d,t),T(:,["Date","Turb"]),G)
legend("Depth="+GID)
  6 件のコメント
Anna
Anna 2025 年 2 月 12 日
Thank you again
Voss
Voss 2025 年 2 月 12 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by