Calculate column means ignoring NaN values in a matrix

  • Topic: MATLAB 
  • Thread starter member 428835
  • Start date
  • Tags Tags
    Average Columns
2 replies · 2K views · last reply
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!