Remove table columns that contain any 'Inf' value
7 views (last 30 days)
Show older comments
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)));
0 Comments
Answers (1)
C B
on 6 Oct 2021
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
0 Comments
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!