function m = tsnanstd(x)

% Finds std after excluding NaNs
m = NaN*ones([1 size(x,2)]);

%% If x is a vector m must -> scalar
if min(size(x))==1
    x = x(:);
end

%% Find std
for k=1:size(x,2)
    I = find(~isnan(x(:,k)));
    if ~isempty(I)
        m(k) = std(x(I,k));
    end
end

    