MATLAB: Error in opening netcdf nc4 files

MATLABnetcdf

Dear all
I have an error when I try to read data in netcdf files. Basically, I used a file list and a loop to fill a matrix with data in a 3-D output (called "DATA") ; I have the same error when I simply open this file with netcdf.open or if I try to look at its info with ncinfo or ncdisp;
>> DATA(i,:,:)=ncread(NAME_file(M(i),:),'precipitationCal');
Error using internal.matlab.imagesci.nc/openToRead (line 1272)
Could not open 3B-HHR.MS.MRG.3IMERG.20130101-S000000-E002959.0000.V06B.HDF5.nc4 for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 61)
ncObj = internal.matlab.imagesci.nc(ncFile);
But when I look into this file with "ncdump" for example, there are data in it that can be read
>> !ncdump 3B-HHR.MS.MRG.3IMERG.20130101-S000000-E002959.0000.V06B.HDF5.nc4 | head
netcdf \3B-HHR.MS.MRG.3IMERG.20130101-S000000-E002959.0000.V06B.HDF5 {
dimensions:
time = 1 ;
lon = 3600 ;
lat = 801 ;
variables:
float precipitationCal(time, lon, lat) ;
precipitationCal:DimensionNames = "time,lon,lat" ;
precipitationCal:Units = "mm/hr" ;
precipitationCal:units = "mm/hr" ;
Any idea to solve this issue ?
Thank you in advance
Vincent

Best Answer

The error is related to extra blank space at the end of the file names ...
>> DATA(i,:,:)=ncread(NAME_file(M(i),1:64),'precipitationCal');
makes the job
V