As AP correctly points out, you can use the function ISFINITE to find and keep only finite values in your matrix. You can also use the function ISNAN. However, removing values from your matrix can have the unintended consequence of reshaping your matrix into a row or column vector:
>> mat = [1 2 3; 4 NaN 6; 7 8 9] %# A sample 3-by-3 matrix
mat =
1 2 3
4 NaN 6
7 8 9
>> mat = mat(~isnan(mat)) %# Removing the NaN gives you an 8-by-1 vector
mat =
1
4
7
2
8
3
6
9
Another alternative is to use some functions from the Statistics Toolbox (if you have access to it) that are designed to deal with matrices containing NaN values. Since you mention taking averages, you may want to check out NANMEAN:
>> mat = [1 2 3; 4 NaN 6; 7 8 9];
>> nanmean(mat)
ans =
4 5 6 %# The column means computed by ignoring NaN values
EDIT: To answer your additional question on the use of XLSWRITE, this sample code should illustrate one way you can write your data:
C = {'time','count','length','width'}; %# A cell array of strings
M = rand(10,20); %# A 10-by-20 array of random values
xlswrite('test.xls',C); %# Writes C to cells A1 through D1
xlswrite('test.xls',M,'A2:T11'); %# Writes M to cells A2 through T11