Trying to create new column which is col1/col2, but function explodes because col 1 and 2 are sometimes 0 or NAN. How do I make the function ignore those?

1 view (last 30 days)
xander fong
xander fong on 24 Jul 2015
Answered: Walter Roberson on 24 Jul 2015
Hello, I have a large data table, 1501x15. I'm trying to create a 16th column which is equal to two columns divided by each other. My code so far is: T.col16=T.col14/t.col12. However, the data sometimes contains zeros in both col14 and col 12, or NaNs. So, the function explodes returning "Warning: Rank deficient, rank = 0, tol = NaN." and returns infinite columns of zeros. How do I make the function ignore the rows which make it explode, putting zeros in the resulting column instead?

Answers (1)

Walter Roberson
Walter Roberson on 24 Jul 2015
T.col16 = T.col14 ./ t.col12;

Community Treasure Hunt

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

Start Hunting!