Extract rows from table fullfilling the condition of interval

조회 수: 1 (최근 30일)
Filip Kauciarik
Filip Kauciarik 2020년 4월 3일
편집: Peng Li 2020년 4월 3일
Problem with measured data from service software in log. I am able to read these log files
data = readtable('wimodlr_rlt_2019-12-09_09-46-07_LoRa SF12_LoRa BW 1600')
and i need to extract the rows according to % of PER. But these numbers are in this format:
data =
169×7 table
No_ Port HostTime DnLnkTx DnLnkRx DnLnkPER PeerRSSI
___ ________ ___________________ _______ _______ ___________ ___________
136 {'COM4'} 2019-12-09 09:47:08 136 125 {'8.09 %' } {'-65 dBm'}
137 {'COM4'} 2019-12-09 09:47:09 137 125 {'8.76 %' } {'-65 dBm'}
138 {'COM4'} 2019-12-09 09:47:09 138 125 {'9.42 %' } {'-65 dBm'}
139 {'COM4'} 2019-12-09 09:47:09 139 125 {'10.07 %'} {'-65 dBm'}
140 {'COM4'} 2019-12-09 09:47:10 140 125 {'10.71 %'} {'-65 dBm'}
141 {'COM4'} 2019-12-09 09:47:10 141 125 {'11.35 %'} {'-65 dBm'}
I need to filter only rows which fullfill the requirement for example: DnLNkPER<10% and DnLNkPER>9% with conversion of strings to double.

답변 (1개)

Peng Li
Peng Li 2020년 4월 3일
편집: Peng Li 2020년 4월 3일
You may want to convert that specific column to double format, and the conditional operation would become easier.
% a test
tbl.test = {'10%', '15.6%', '29.0%', '30%', '11%'}';
tbl = struct2table(tbl)
tbl =
5×1 table
test
_________
{'10%' }
{'15.6%'}
{'29.0%'}
{'30%' }
{'11%' }
% convert column to double
tbl.test = cellfun(@(x) str2double(x(1:end-1)) ./ 100, tbl.test)
tbl =
5×1 table
test
_____
0.1
0.156
0.29
0.3
0.11

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by