Borrar filtros
Borrar filtros

Is it possible to create a plot from a table?

5 visualizaciones (últimos 30 días)
Hans Lipton
Hans Lipton el 1 de Nov. de 2021
Comentada: Star Strider el 1 de Nov. de 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?

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by