Removing NaN from an array in a table

5 Ansichten (letzte 30 Tage)
Sonali
Sonali am 26 Dez. 2023
Kommentiert: Sonali am 28 Dez. 2023
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 Kommentare
Sonali
Sonali am 28 Dez. 2023
please check the data link above
Sonali
Sonali am 28 Dez. 2023
I tried rmmissing. It didnt work with the current dataset.
Splitvars is for columns. Here we have multirows in each row of the table.
Here's the datafile, in case someone needs and can provide a better solution.
https://drive.google.com/file/d/16MKcQ0Yfbpy8WKixvtL-OeEixdrwa8mL/view?usp=sharing

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rangesh
Rangesh am 26 Dez. 2023
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)
patients = 5×4 table
LastName Age Weight BloodPressure _________ ___ ______ _____________ "Sanchez" 38 176 NaN NaN "Johnson" 43 163 109 77 "Zhang" 38 131 125 83 "Diaz" 40 133 NaN 75 "Brown" 49 119 122 80
Splitting the variable across the columns of "BloodPressure".
splitvars(patients,'BloodPressure')
ans = 5×5 table
LastName Age Weight BloodPressure_1 BloodPressure_2 _________ ___ ______ _______________ _______________ "Sanchez" 38 176 NaN NaN "Johnson" 43 163 109 77 "Zhang" 38 131 125 83 "Diaz" 40 133 NaN 75 "Brown" 49 119 122 80
Removing the NaN values from the table.
rmmissing(patients)
ans = 3×4 table
LastName Age Weight BloodPressure _________ ___ ______ _____________ "Johnson" 43 163 109 77 "Zhang" 38 131 125 83 "Brown" 49 119 122 80
For further understanding on the functions used, please do refer the following documentation:
I hope this resolves your query.
Thanks,
Rangesh.
  1 Kommentar
Sonali
Sonali am 28 Dez. 2023
I tried rmmissing. It didnt work with the current dataset.
Splitvars is for columns. Here we have multirows in each row of the table.
Here's the datafile, in case someone needs and can provide a better solution.
https://drive.google.com/file/d/16MKcQ0Yfbpy8WKixvtL-OeEixdrwa8mL/view?usp=sharing

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by