Extract element from a table

조회 수: 3 (최근 30일)
Gaetano Pavone
Gaetano Pavone 2021년 11월 10일
답변: Steven Lord 2021년 11월 10일
I have a 56x4 table in which first column collects strings, while the other columns have non-null number.
edgetable=table(edgetype,edgeindex,firstnode,secondnode);
I would like to extract edgeindexes such that edgetype is equal, e.g., to "CSE".

채택된 답변

Steven Lord
Steven Lord 2021년 11월 10일
Let's make a sample table.
rng default
listOfTypes = ["apple"; "banana"; "cherry"];
T = listOfTypes(randi(numel(listOfTypes), 5, 1));
x = randi(10, 5, 1);
tt = table(T, x)
tt = 5×2 table
T x ________ __ "cherry" 1 "cherry" 3 "apple" 6 "cherry" 10 "banana" 10
theCherries = tt(tt.T == "cherry", :)
theCherries = 3×2 table
T x ________ __ "cherry" 1 "cherry" 3 "cherry" 10

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by