Hi Kishore,
I understand you have a large data set and you are processing your data for analysis. You faced an issue while calculating mean, since you large data set contains NaN values in some places in your data file.
It is known the mean function in MATLAB return NaN if any of the input values are NaN, which can lead to unexpected results. To exclude NaN values from the calculations, you can use the 'omitnan' option available in MATLAB's mean function. Here's a sample function to calculate mean:
[mean_val] = calculate_mean(matrix)
% Calculate the mean excluding NaN values
mean_val = mean(matrix, 'omitnan');
end
Now the function will correctly calculate the mean and standard deviation of the given matrix, excluding any NaN values.
Refer to the documentation of mean for further information:
Hope this helps!