Error using ' TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or PERMUTE to reorder dimensions of N-D arrays.
11 Ansichten (letzte 30 Tage)
Madison am 3 Jun. 2023
The data is from Copernicus, but sea surface height (SHW) is a 3D matirx
dir = 'C:\Users\Madison-Riley\Downloads\';
ncfile = 'PotentialTemp.nc'; % name of data file from copernicus
lon = ncread([dir,ncfile], 'longitude');
lat = ncread([dir,ncfile], 'latitude');
depth = ncread([dir,ncfile], 'depth');
time = ncread([dir,ncfile], 'time');
% note 'squeeze' function gets rid of the single dimension (depth=1):
temp= squeeze(ncread([dir,ncfile], 'thetao')); % Sea water potential temperature (long,lat,depth(=1),time)
% plot temp for time t=1:
Walter Roberson am 3 Jun. 2023
Your nc file has lat, long, one depth, and multiple times, making it a 4 dimensional array. You are trying to pcolor() the entire 4d array at the same time. pcolor can only handle 2d data.
The error with transpose is a side show. You could permute() [2 1 3 4] instead of ' but the resulting array would still be 4d and pcolor cannot handle that. You should extract the data for one time for each pcolor, possibly looping animating over time