Borrar filtros
Borrar filtros

Convert Logical Column to Table

9 visualizaciones (últimos 30 días)
Theodore
Theodore el 11 de Mzo. de 2023
Respondida: Star Strider el 11 de Mzo. de 2023
How does one append a Nx1 logical to the right of a Nx4 table?
I assumed this would be a matter of horzcat(initialTable, logicalColumn)
But, I recieve an error of "All input arguments must be tables."
So the real question is:
how to convert the Nx1 logical column to a "table", such that I can horzcat the tables?
Thank you

Respuesta aceptada

Star Strider
Star Strider el 11 de Mzo. de 2023
Use the addvars function —
T1 = array2table(rand(10,4), 'VariableNames',{'A','B','C','D'})
T1 = 10×4 table
A B C D _______ _______ ________ ________ 0.94355 0.46999 0.6111 0.49835 0.16236 0.77156 0.070068 0.30287 0.39682 0.21807 0.6177 0.22845 0.19572 0.73545 0.072427 0.98402 0.24671 0.24431 0.40432 0.49477 0.30326 0.28484 0.5922 0.02865 0.14205 0.33359 0.94847 0.69256 0.62436 0.21889 0.70145 0.060852 0.69664 0.75923 0.42365 0.66119 0.6537 0.12065 0.65835 0.017138
LogicalVector = rand(10,1)>0.5;
T1 = addvars(T1,LogicalVector,'After','D')
T1 = 10×5 table
A B C D LogicalVector _______ _______ ________ ________ _____________ 0.94355 0.46999 0.6111 0.49835 false 0.16236 0.77156 0.070068 0.30287 true 0.39682 0.21807 0.6177 0.22845 false 0.19572 0.73545 0.072427 0.98402 false 0.24671 0.24431 0.40432 0.49477 true 0.30326 0.28484 0.5922 0.02865 true 0.14205 0.33359 0.94847 0.69256 false 0.62436 0.21889 0.70145 0.060852 false 0.69664 0.75923 0.42365 0.66119 true 0.6537 0.12065 0.65835 0.017138 false
.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by