Add Rows from Structure
You also can append new rows stored in a structure. Convert the structure to a table, and then
concatenate the tables.
structPatients(1,1).LastName = 'George';
structPatients(1,1).Gender = 'Male';
structPatients(1,1).Age = 45;
structPatients(1,1).Height = 76;
structPatients(1,1).Weight = 182;
structPatients(1,1).Smoker = 1;
structPatients(1,1).Systolic = 132;
structPatients(1,1).Diastolic = 85;
structPatients(2,1).LastName = 'Hadley';
structPatients(2,1).Gender = 'Female';
structPatients(2,1).Age = 29;
structPatients(2,1).Height = 58;
structPatients(2,1).Weight = 120;
structPatients(2,1).Smoker = 0;
structPatients(2,1).Systolic = 112;
structPatients(2,1).Diastolic = 70;
Tnew = [Tnew;struct2table(structPatients)];
size(Tnew)
ans = 1×2
108
8
Omit Duplicate Rows
To omit any rows in a table that are duplicated, use the unique function.
Tnew = unique(Tnew);
size(Tnew)
ans = 1×2
106
8
unique deleted two duplicate rows.
Delete Rows by Row Number
Delete rows 18, 20, and 21 from the table.
Tnew([18,20,21],:) = [];
size(Tnew)
ans = 1×2
103
8
The table contains information on 103 patients now.
9 Tables
9-10
Précédent

- 354/1450

Suivant