i cant use nanmean for this
how to do mean of a column with a loop and excluding nans?
1 view (last 30 days)
Show older comments
Commented: Birdman on 16 Mar 2018
so i have this large file that is contains nans randomly, its a 1140 X 1 matrix i want to do a for loop that excludes all the nans and do the mean of that can someone explain me how to do this?
Edited: Birdman on 16 Mar 2018
You do not need a for loop. Matlab's mean function has an option of omitnan. You can use it as follows:
res is used to sum up the variables that are not NaN, that is it. You need a variable to sum up the variables that are not NaN in a for loop, therefore you need it and cnt simply counts how many times that if statement is entered.
More Answers (0)
Find more on Loops and Conditional Statements 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!