table select rows with string/value of two colums
2 次查看(过去 30 天)
显示 更早的评论
Hi,
Following problem: I have a table with values for different categories (FKM, page), which is used to guide the further processing of the data. Since I only have 1 value for some categories and 2, 3, .. for others, the table cannot be evaluated with a for loop. How can I select rows based on a command like : Select all values that have value 113 in column FKM and L in page Can someone help me ? Here is an example from the table
___X______________Y___________________Z_________FKM____Seite_____________ObjArt_____________Var1__Var2....... 2222_________________________________
704306.281000000 5364346.78000000 440.678000000000 113 'R' 'AX_UnlandVegetationsloseFlaeche' 0 0 0 0 0 0
704128.356000000 5364559.83000000 442.202000000000 113 'L1' 'AX_SportFreizeitUndErholungsflaeche' 0 0 0 0 0 0
704102.320000000 5364597.45400000 441.863000000000 113 ' L2' 'AX_SportFreizeitUndErholungsflaeche' 0 0 0 0 0 0
703329.753000000 5363882.45200000 443.274000000000 114 ' L' 'AX_SportFreizeitUndErholungsflaeche' 0 0 0 0 0 0
703686.786000000 5363755.10600000 443.384000000000 114 'R' 'AX_Gehoelz' 0 0 0 0 0 0
702984.012000000 5363011.86700000 444.843000000000 115 'L' 'AX_UnlandVegetationsloseFlaeche' 0 0 0 0 0 0
703418.892000000 5362702.32900000 445.046000000000 115 'R' 'AX_Gehoelz' 0 0 0 0 0 0
702520.915000000 5362127.03000000 445.696000000000 116 'L1' 'AX_Wald' 0 0 0 0 0 0
702916.399000000 5361892.60400000 445.880000000000 116 'R1' 'AX_Wald' 0 0 0 0 0 0
702499.970000000 5362137.68000000 446.443000000000 116 'L2' 'AX_Landwirtschaft' 0 0 0 0 0 0
703151.189000000 5361748.81700000 446.536000000000 116 'R2' 'AX_Landwirtschaft' 0 0 0 0 0 0
702109.300000000 5361227.85000000 447.913000000000 117 'L1' 'AX_Wald' 0 0 0 0 0 0
Thanks
0 个评论
回答(1 个)
Chunru
2022-6-23
编辑:Chunru
2022-6-23
data ={
704306.281000000 5364346.78000000 440.678000000000 113 'R' 'AX_UnlandVegetationsloseFlaeche' 0 0 0 0 0 0
704128.356000000 5364559.83000000 442.202000000000 113 'L1' 'AX_SportFreizeitUndErholungsflaeche' 0 0 0 0 0 0
704102.320000000 5364597.45400000 441.863000000000 113 ' L2' 'AX_SportFreizeitUndErholungsflaeche' 0 0 0 0 0 0
703329.753000000 5363882.45200000 443.274000000000 114 ' L' 'AX_SportFreizeitUndErholungsflaeche' 0 0 0 0 0 0
703686.786000000 5363755.10600000 443.384000000000 114 'R' 'AX_Gehoelz' 0 0 0 0 0 0
702984.012000000 5363011.86700000 444.843000000000 115 'L' 'AX_UnlandVegetationsloseFlaeche' 0 0 0 0 0 0
703418.892000000 5362702.32900000 445.046000000000 115 'R' 'AX_Gehoelz' 0 0 0 0 0 0
702520.915000000 5362127.03000000 445.696000000000 116 'L1' 'AX_Wald' 0 0 0 0 0 0
702916.399000000 5361892.60400000 445.880000000000 116 'R1' 'AX_Wald' 0 0 0 0 0 0
702499.970000000 5362137.68000000 446.443000000000 116 'L2' 'AX_Landwirtschaft' 0 0 0 0 0 0
703151.189000000 5361748.81700000 446.536000000000 116 'R2' 'AX_Landwirtschaft' 0 0 0 0 0 0
702109.300000000 5361227.85000000 447.913000000000 117 'L1' 'AX_Wald' 0 0 0 0 0 0
};
T = cell2table(data);
% How can I select rows based on a command like : Select all values that have value 113 in
% column FKM and L in page Can someone help me ? Here is an example from the table
T.data5 = strtrim(string(T.data5))
selected = T(T.data4 == 113 & T.data5=="L1", :) % use your column names if different
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!