我看到File Exchange有一个有人创建的函数gebconetcdf,然后我发现了我需要的代码:
gebconc=netcdf.open('gebco_2021_n60.0_s10.0_w-90.0_e-40.0.nc','NOWRITE');
XGRID=netcdf.getVar(gebconc,0);
YGRID=netcdf.getVar(gebconc,1);
BATHY=netcdf.getVar(gebconc,2);
netcdf.close(gebconc);