Matlab read table of values
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a table of data. Column 1 is a building ID #. Column 2-7 are contact names. Data is entered such that the building ID# could repeat. I'm looking to pull names from column 2-7 for each building ID #. So row 1-5 maybe building 100 and row 6 and 7, are building 101. It is unknown how many rows are duplicate building #'s. In the end, i'd like to create an output for each building # that cintains all the names from column 2-7 for each row the building # was the same. Make sense?
댓글 수: 5
Lei Hou
2022년 8월 31일
Hi Sudo,
Does the following solution solve your problem?
>> BuildingID = [100;100;100;100;100;101;101];
>> column2 = ["A";"B";"C";"D";"E";"F";"G"];
>> t = table(BuildingID, column2, column2, column2, column2, column2, column2, 'VariableNames',{'BuildingID' 'column2' 'column3' 'column4' 'column5' 'column6' 'column7'})
t =
7×7 table
BuildingID column2 column3 column4 column5 column6 column7
__________ _______ _______ _______ _______ _______ _______
100 "A" "A" "A" "A" "A" "A"
100 "B" "B" "B" "B" "B" "B"
100 "C" "C" "C" "C" "C" "C"
100 "D" "D" "D" "D" "D" "D"
100 "E" "E" "E" "E" "E" "E"
101 "F" "F" "F" "F" "F" "F"
101 "G" "G" "G" "G" "G" "G"
>> t(t.BuildingID==100,:)
ans =
5×7 table
BuildingID column2 column3 column4 column5 column6 column7
__________ _______ _______ _______ _______ _______ _______
100 "A" "A" "A" "A" "A" "A"
100 "B" "B" "B" "B" "B" "B"
100 "C" "C" "C" "C" "C" "C"
100 "D" "D" "D" "D" "D" "D"
100 "E" "E" "E" "E" "E" "E"
>> t(t.BuildingID==101,:)
ans =
2×7 table
BuildingID column2 column3 column4 column5 column6 column7
__________ _______ _______ _______ _______ _______ _______
101 "F" "F" "F" "F" "F" "F"
101 "G" "G" "G" "G" "G" "G"
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!