I am trying to make a contour plot from an output netcdf file from my oceanic simulation. I am using a netcdf file and want a single plot with variables u,v and w . The dimension of variables I am using are as follows:
u
Size: 99x50x15x273
Dimensions: xi_u,eta_u,s_rho,ocean_time
Datatype: single
Attributes:
long_name = 'u-momentum component'
units = 'meter second-1'
time = 'ocean_time'
grid = 'grid'
location = 'edge1'
coordinates = 'lon_u lat_u s_rho ocean_time'
v
Size: 99x50x15x273
Dimensions: xi_v,eta_v,s_rho,ocean_time
Datatype: single
Attributes:
long_name = 'v-momentum component'
units = 'meter second-1'
time = 'ocean_time'
grid = 'grid'
location = 'edge1'
coordinates = 'lon_v lat_v s_rho ocean_time'
w
Size: 99x50x15x273
Dimensions: xi_u,eta_w,s_rho,ocean_time
Datatype: single
Attributes:
long_name = 'w-momentum component'
units = 'meter second-1'
time = 'ocean_time'
grid = 'grid'
location = 'edge1'
coordinates = 'lon_w lat_w s_rho ocean_time'
I am unable to write a matlab script for it that plots the combined effect of all these variables that is total = sqrt( u*u + v*v +w*w) into a plot.
It would be of great help if anyone could help me with the script as I am a beginner in MATLAB and need to do this for my project purpose. I have attached my file
I am attaching the code I wrote and I know it's not even correct to any degree:
File = ‘Lombok_roms_his.nc’
Lat = ncread(File,’lat’);
Lon = ncread(File,’lon’);
U = ncread(File,’u’);
V = ncread(File,’v’);
W = ncread(File,’w’);
Total = sqrt(U*U + V*V + W*W);
pcolor(lon,lat,Total(:,:,:,1)')
[m,n,p] = size(Total) ;
for i = 1:p
pcolor(Lat,Lon,Total(:,:,:i)')
shading interp
colorbar
drawnow
end