Not sure if this is the best way but it works and its fast:
file = 'C:\Users\Jason\Documents\MATLAB\sgData\sg135\p1350050.nc';
ncid = netcdf.open(file,'nowrite');
str = 'good';
var = 'u_da';
try
ID = netcdf.inqVarID(ncid,var);
catch exception
if strcmp(exception.identifier,'MATLAB:imagesci:netcdf:libraryFailure')
str = 'bad';
end
end
netcdf.close(ncid)
disp(str)