Is it possible to create a plot from a table?

10 views (last 30 days)
I have a table and I'd like to create several plots from it.
Is it easier to create a plot from a table or matrix?

Accepted Answer

Star Strider
Star Strider on 1 Nov 2021
Creating a plot from a table is straightforward, although the references are different —
T1 = array2table(randi(99, 5,3), 'VariableNames',{'Column 1','X','v'})
T1 = 5×3 table
Column 1 X v ________ __ __ 96 28 50 36 18 31 49 44 45 58 69 59 91 54 62
figure
plot(T1.('Column 1'), T1.X, 'p')
hold on
plot(T1.('Column 1'), T1.v, 's')
hold off
grid
If the first column is a datetime array, this is also straightforward —
T2 = table(datetime([2021 11 01])+days(0:4).', rand(5,1), randn(5,1))
T2 = 5×3 table
Var1 Var2 Var3 ___________ ________ ________ 01-Nov-2021 0.099591 1.173 02-Nov-2021 0.35676 0.2072 03-Nov-2021 0.35601 0.58294 04-Nov-2021 0.38944 -0.63081 05-Nov-2021 0.1249 0.050471
figure
plot(T2{:,1}, T2{:,2}, 'p')
hold on
plot(T2{:,1}, T2{:,3}, 's')
hold off
grid
.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!