You can use the functions provided in Matlab, such as isnan and find, to filter the data by conditions, and then use the mean function to calculate the daily mean, the specific steps are as follows:

Step1: Use isnan function to get all NaN values, and store the results in logical variable;

Step2: Screen out

Method 1:

1 according to the content of logical variable. Use the Matlab built-in functions find and isnan to find and determine the number of NaN values in each daily data.

2. Use the built-in function mean in Matlab to calculate the daily mean value and ignore the NaN value.

3. Judge whether the number of NaN values in a day is greater than 40%. If so, the mean value of the day is regarded as invalid.

Method 2

Method 1:

1. You can use the find function of Matlab to find out the index number of NaN value, that is, find out all NaN and store it in a matrix. 2. Use Matlab's reshape function, and stretch the matrix into a column, with 48 elements in each row. This splits the day's data.

3. First of all, the original data can be screened according to the requirements, and only the data that meets the requirements can be placed in the same variable:

% Extract the data that meets the conditions

data_valid = rawdata(~isnan(rawdata));

% Filters by day

num_data = length(rawdata); % Data total

num_day = num_data/48; % Days

samples= reshaping(data_valid, 48, num_day); %

Use Matlab's find command to help filter NaN values. In addition, the daily mean of this dataset can be computed using the nanmean function, which automatically skips the NaN value calculation without further filtering.

For the data values of each day, first use the find command to find the number of NaN values, and then the total number. First, function reshaping and nanmean in Matlab can be used to solve.

First, use the reshaping function to rearrange the original data into the result of sampling 48 times a day. for example, for a data of 88 days, an 88x48 matrix can be reconstructed, and the element of nan can be changed to 0. In this way, each of the processed matrix can use Matlab's for loop statements. Judge whether the number of NaN values of each day exceeds 40%. If not, all the effective values of the day are summed up and recorded, and then divided by the number of effective values to get the average value of the day.