Remove table columns that contain any 'Inf' value

조회 수: 14 (최근 30일)
chiefjia
chiefjia 2021년 10월 6일
답변: C B 2021년 10월 6일
Dear MATLAB experts,
I'm trying to remove all columns from a table that contain (once or more) so called 'Inf' values. I have tried the code below so far, but it has not worked. Thank you in advance.
stock_returnsTable = stock_returnsTable(:,~any(isinf(stock_returns)));

답변 (1개)

C B
C B 2021년 10월 6일
modified = stock_returnsTable{:,:}
output = modified(:, all(~isinf(modified), 1))
stock_returnsTable =
5×4 table
A B C D
__ ___ ___ ___
71 176 Inf 12
69 163 163 163
64 131 131 131
67 133 133 133
64 Inf 33 33
modified =
71 176 Inf 12
69 163 163 163
64 131 131 131
67 133 133 133
64 Inf 33 33
output =
71 12
69 163
64 131
67 133
64 33

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by