Calculate column means ignoring NaN values in a matrix

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Average Columns
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
member 428835
Hi PF!

Given a matrix A = [1 2; nan 3; 3 4], how can I calculate the mean so that the resulting matrix averages the columns but ignores the nan values as non-entries, so that the mean of matrix A outputs [2,3]?

Thanks so much!
 
Physics news on Phys.org
Hey thanks Wrichik Basu! Big help! I appreciate your time!
 
Reply
  • Like
Likes   Reactions: Wrichik Basu