Let's suppose you have data similar with the following example, and you want to compute the mean value from the data:
data = [1 2 nan 3 nan 10]
If you have the Stats toolbox, use nanmean:
nanmean(data)
Otherwise, here is a line of code that you can use:
mean(data(~isnan(data)))