The data im using is shown below. as you can see there are multiple values for temperature and salinity at each lat lon location due to multiple time intervals. I want to average the temperatures and salinity respectively at each location to plot a pcolor of the average temp and salinity over the entire time period. Does anyone know how to average the 4D matrix int a 3D matrix?
Dimensions: [1x4 struct] Variables: [1x6 struct] Attributes: [1x15 struct] Groups: [] Format: 'classic'Format: classicGlobal Attributes: title = 'monthly mean fields from Global Ocean Physics Analysis and Forecast updated monthly' institution = 'Mercator Ocean' references = 'http://marine.copernicus.eu' source = 'MERCATOR PSY4QV3R1' Conventions = 'CF-1.0' history = 'Data extracted from dataset http://opendap-glo.mercator-ocean.fr:8080/thredds/dodsC/global-analysis-forecast-phy-001-024-monthly' time_min = 543852 time_max = 569412 julian_day_unit = 'hours since 1950-01-01' z_min = 55.7643 z_max = 55.7643 latitude_min = -8 latitude_max = -2 longitude_min = 69 longitude_max = 80Dimensions: time = 36 depth = 1 latitude = 73 longitude = 133Variables: time Size: 36x1 Dimensions: time Datatype: int32 Attributes: units = 'hours since 1950-01-01' axis = 'T' long_name = 'Time (hours since 1950-01-01)' standard_name = 'time' calendar = 'gregorian' _CoordinateAxisType = 'Time' so Size: 133x73x1x36 Dimensions: longitude,latitude,depth,time Datatype: int16 Attributes: _CoordinateAxes = 'time depth latitude longitude ' _FillValue = -32767 long_name = 'Salinity' standard_name = 'sea_water_salinity' units = '1e-3' unit_long = 'Practical Salinity Unit' cell_methods = 'area: mean' add_offset = -0.0015259 scale_factor = 0.0015259 thetao Size: 133x73x1x36 Dimensions: longitude,latitude,depth,time Datatype: int16 Attributes: _CoordinateAxes = 'time depth latitude longitude ' _FillValue = -32767 long_name = 'Temperature' standard_name = 'sea_water_potential_temperature' units = 'degrees_C' unit_long = 'Degrees Celsius' cell_methods = 'area: mean' add_offset = 21 scale_factor = 0.00073244 longitude Size: 133x1 Dimensions: longitude Datatype: single Attributes: _FillValue = NaN step = 0.083328 units = 'degrees_east' unit_long = 'Degrees East' long_name = 'Longitude' standard_name = 'longitude' axis = 'X' _CoordinateAxisType = 'Lon' latitude Size: 73x1 Dimensions: latitude Datatype: single Attributes: _FillValue = NaN step = 0.083336 units = 'degrees_north' unit_long = 'Degrees North' long_name = 'Latitude' standard_name = 'latitude' axis = 'Y' _CoordinateAxisType = 'Lat' depth Size: 1x1 Dimensions: depth Datatype: single Attributes: _FillValue = NaN units = 'm' positive = 'down' unit_long = 'Meters' long_name = 'Depth' standard_name = 'depth' axis = 'Z' _CoordinateAxisType = 'Height' _CoordinateZisPositive = 'down'
Best Answer