Removing NaN from an array in a table
Mostrar comentarios más antiguos
I opened a cdf file and saved the data in a table. It has arrays in the table's rows. Is there anyway we can make a single table with the rows of arrays as a part of table?
data file:
4 comentarios
Anton Kogios
el 26 de Dic. de 2023
Are you able to share the cdf file please?
Walter Roberson
el 26 de Dic. de 2023
See splitvars
Sonali
el 28 de Dic. de 2023
Sonali
el 28 de Dic. de 2023
Respuestas (1)
Hi Sonali,
I understand that you are looking to separate the rows of array present in the table to individual columns in the table and remove the NaN values from the table.
Here is reference code on how to address this issue:
Creating table "patients” containing a multicolumn variable “BloodPressure” which contains “NaN” values.
LastName = ["Sanchez";"Johnson";"Zhang";"Diaz";"Brown"];
Age = [38;43;38;40;49];
Weight = [176;163;131;133;119];
BloodPressure = [NaN NaN; 109 77; 125 83; NaN 75; 122 80];
patients = table(LastName,Age,Weight,BloodPressure)
Splitting the variable across the columns of "BloodPressure".
splitvars(patients,'BloodPressure')
Removing the NaN values from the table.
rmmissing(patients)
For further understanding on the functions used, please do refer the following documentation:
- splitvars: Splits the multicolumn variable. https://www.mathworks.com/help/matlab/ref/table.splitvars.html
- rmmissing: Removes the missing entry from an array or table. https://www.mathworks.com/help/matlab/ref/rmmissing.html
I hope this resolves your query.
Thanks,
Rangesh.
1 comentario
Sonali
el 28 de Dic. de 2023
Categorías
Más información sobre Tables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!