Is it possible to create a plot from a table?

15 vues (au cours des 30 derniers jours)
Hans Lipton
Hans Lipton le 1 Nov 2021
Commenté : Star Strider le 1 Nov 2021
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?

Réponse acceptée

Star Strider
Star Strider le 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
.
  2 commentaires
Hans Lipton
Hans Lipton le 1 Nov 2021
Thank you very much! Helps a lot.
Star Strider
Star Strider le 1 Nov 2021
As always, my pleasure!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by