Error reading uo file

Error in untitled (line 52)
u1 = ncread(fullfile(filename,'uo'),[1 1 nz 1],[length(lon) length(lat) 1 ntime]);
for yi=1:nyear
ny=ystart+yi-1
filename=fullfile(fp,['June' num2str(ny) '.nc']);
u1 = ncread(fullfile(filename,'uo'),[1 1 nz 1],[length(lon) length(lat) 1 ntime]);
v1 = ncread(fullfile(filename,'uo'),[1 1 nz 1],[length(lon) length(lat) 1 ntime])
% if you want monthly averages, do this
% note this will end up a different dimension if you're extracting
% multiple layers
% might want to predefine these matrices depending on what you want
% https://uk.mathworks.com/help/matlab/ref/mean.html
u2(:,:,yi)=mean(u1,[4]); whos u2
v2(:,:,yi)=mean(v1,[4]);
end
% then take the mean to get the mean over all the years, for one depth
% layer only, remember
u3=mean(u2,[3]); %taking the mean over the third dimension
v3=mean(u2,[3]);
% calculate the magnitude of the vel and plot
uv4=sqrt(u3.^2+v3.^2);
close all, pcolor(LON,LAT,uv4.'), shading flat, colorbar

Risposte (1)

VBBV
VBBV il 19 Lug 2023
u1 = ncread(filename,'uo',[1 1 nz 1],[length(lon) length(lat) 1 ntime]);
v1 = ncread(filename,'uo',[1 1 nz 1],[length(lon) length(lat) 1 ntime]);

4 Commenti

VBBV
VBBV il 19 Lug 2023
try without using fullfile and extra parenthesis
Madison
Madison il 19 Lug 2023
I still get the same error, this is the full error.
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of 'getVarsFloat' function - 'Start+count
exceeds dimension bound (NC_EEDGE)'.
Error in netcdf.getVar (line 205)
data = matlab.internal.imagesci.netcdflib(funcstr,ncid,varid,varargin{:});
Error in internal.matlab.imagesci.nc/read (line 690)
data = netcdf.getVar(gid, varid, ...
Error in ncread (line 76)
vardata = ncObj.read(varName, varargin{:});
Error in untitled (line 52)
u1 = ncread(filename,'uo',[1 1 nz 1],[length(lon) length(lat) 1 ntime]);
VBBV
VBBV il 19 Lug 2023
See the above question / answer which discusses similar issue, I think its related with Version and /or file limit contents
Madison
Madison il 19 Lug 2023
I altered my data, as it was a typo and teh variables should have been uo and vo for u1 and v1, but I get the same error.

Accedi per commentare.

Categorie

Prodotti

Release

R2023a

Tag

Richiesto:

il 19 Lug 2023

Commentato:

il 19 Lug 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by