Borrar filtros
Borrar filtros

StackedPlot with two tables with specific variables

7 visualizaciones (últimos 30 días)
Bhargav
Bhargav el 9 de Feb. de 2024
Comentada: Bhargav el 9 de Feb. de 2024
I have two tables say table A and table B. A and B has different number of variables but the same number of rows.
following the syntax of stackedplot if I want to do a stackedplot for A
I would write something like this stackedplot(A,[''variable name 1''," [variable name 2']")
My question:
I want to have stacked plot of two tables A and B but specific variables from table A and specific variables from table B
stackedplot(A,["variable1ofA","var2ofA", "var3ofA"],B,["var1ofB","var2ofB"])
The syntax for multiple table is stackedplot(tbl1,tabl2) how do I specify which variables of each table ?
How can I achieve this ?
Thank you

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 9 de Feb. de 2024
If they have the same number of rows, I think what you would want to do is
T = [A(:,["variable1ofA","var2ofA", "var3ofA"]),B(:,["var1ofB","var2ofB"])]
stackedplot(T)
If the tables do not share the same variable names, this may work as well (untested)
stackedplot([A,B],["variable1ofA","var2ofA", "var3ofA","var1ofB","var2ofB"])
  6 comentarios
Cris LaPierre
Cris LaPierre el 9 de Feb. de 2024
The 2nd syntax should work. I did have to make sure there are no shared variable names between the 2 tables, and that both tables have the same number of rows. Here's a working example.
x = (0:0.1:25).';
TA = array2table([x sin((1:4).*2.*pi.*x/25)]);
TB = array2table([x sin((5:8).*2.*pi.*x/25)]);
TB.Properties.VariableNames = ["X","Y1","Y2","Y3","Y4"];
stackedplot([TA,TB],["Var2","Var3", "Var4","Y1","Y2"])
Bhargav
Bhargav el 9 de Feb. de 2024
ah I see. I think I have one shared variable hence it was giving me a duplicated error

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by