string extraction from a table

4 visualizzazioni (ultimi 30 giorni)
galben
galben il 23 Ott 2022
Commentato: galben il 25 Ott 2022
How can I extract data for the Brown?
I would appreciate some help, i have been stuck with this.
Age = [38;43;38;40;49;45;42;24;50;99];
Smoker = logical([1;0;1;0;1;1;1;0;0;1]);
LastName = {'Brown_Howard';'Johnson';'Lee';'Diaz';'Sanchez';'Brown_loewo';'Grace';'Brown_justin';'Peter';'Brown_002'};
Height = [71;69;64;67;64;67;66;55;45;88];
Weight = [176;163;131;133;100;136;153;131;133;149];
BloodPressure = [124 93; 19 77; 125 83; 117 75; 122 8;14 75; 135 23; 137 25; 142 30;42 30];
T = table(Age,Smoker,LastName, Weight,Height,BloodPressure)

Risposta accettata

Paul
Paul il 23 Ott 2022
Age = [38;43;38;40;49;45;42;24;50;99];
Smoker = logical([1;0;1;0;1;1;1;0;0;1]);
LastName = {'Brown_Howard';'Johnson';'Lee';'Diaz';'Sanchez';'Brown_loewo';'Grace';'Brown_justin';'Peter';'Brown_002'};
Height = [71;69;64;67;64;67;66;55;45;88];
Weight = [176;163;131;133;100;136;153;131;133;149];
BloodPressure = [124 93; 19 77; 125 83; 117 75; 122 8;14 75; 135 23; 137 25; 142 30;42 30];
T = table(Age,Smoker,LastName, Weight,Height,BloodPressure)
T = 10×6 table
Age Smoker LastName Weight Height BloodPressure ___ ______ ________________ ______ ______ _____________ 38 true {'Brown_Howard'} 176 71 124 93 43 false {'Johnson' } 163 69 19 77 38 true {'Lee' } 131 64 125 83 40 false {'Diaz' } 133 67 117 75 49 true {'Sanchez' } 100 64 122 8 45 true {'Brown_loewo' } 136 67 14 75 42 true {'Grace' } 153 66 135 23 24 false {'Brown_justin'} 131 55 137 25 50 false {'Peter' } 133 45 142 30 99 true {'Brown_002' } 149 88 42 30
T(startsWith(T.LastName,'Brown'),:)
ans = 4×6 table
Age Smoker LastName Weight Height BloodPressure ___ ______ ________________ ______ ______ _____________ 38 true {'Brown_Howard'} 176 71 124 93 45 true {'Brown_loewo' } 136 67 14 75 24 false {'Brown_justin'} 131 55 137 25 99 true {'Brown_002' } 149 88 42 30

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by