Remove table columns that contain any 'Inf' value

6 次查看(过去 30 天)
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