MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

You can use the readtable function to read the data in allPatientsBMI.txt into a
new table.


Create a subtable and write the subtable to a separate file. Delete the rows that contain
data on patients who are smokers. Then remove the Smoker variable. nonsmokers
contains data only for the patients who are not smokers.


nonsmokers = T;
toDelete = (nonsmokers.Smoker == true);
nonsmokers(toDelete,:) = [];
nonsmokers.Smoker = [];


Write nonsmokers to a file.


writetable(nonsmokers,'nonsmokersBMI.txt');


See Also


Import Tool | array2table | cell2table | readtable | sortrows | struct2table |
summary | table | writetable


Related Examples



  • “Clean Messy and Missing Data in Tables” on page 9-27

  • “Modify Units, Descriptions, and Table Variable Names” on page 9-34

  • “Access Data in a Table” on page 9-44


More About



  • “Advantages of Using Tables” on page 9-66


See Also
Free download pdf