フィルターのクリア

Error creating matlab pcolor

1 回表示 (過去 30 日間)
Madison
Madison 2023 年 7 月 23 日
回答済み: Voss 2023 年 7 月 23 日
I am running into an error plotting temperature form my file (it contains data from Jan-March)
close all, clear all clc
% note I've renamed the files, call them what you like but they need to
% have the year in them to load in a loop
fp = 'C:\Users\Madison-Riley\Desktop\Thesis\Environmental_Data\Temperature';
ncdisp(fullfile(fp,'Temp_Q1(2020).nc'))
%look at one file to interrogate and understand dimensions and variables
% test=ncread([filepath,'June2021.nc'],'uo'); whos test
time = ncread(fullfile(fp,'Temp_Q1(2020).nc'),'time'); whos time
ntime=length(time);
lon=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'longitude');
lat=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'latitude');
[LON,LAT]=meshgrid(lon,lat);
bottomT=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'bottomT'); whos utide
% dimensions lon*lat*depth*time
% https://uk.mathworks.com/help/matlab/ref/ncread.html
% try different depth layers here, why is the land extent so different?
bottomTtest=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'bottomT',[1 1 1],[length(lon) length(lat) 1 1]);
close all
pcolor(LON,LAT,bottomT.'), shading flat, colorbar
I get the following Error:
Error using internal.matlab.imagesci.nc/read
COUNT has incorrect number of elements (4). The variable has 3 dimensions.
Error in ncread (line 76)
vardata = ncObj.read(varName, varargin{:});
Error in Temp_Q1_20 (line 22)
bottomTtest=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'bottomT',[1 1 1],[length(lon) length(lat) 1 1]);

採用された回答

Voss
Voss 2023 年 7 月 23 日
The error message indicates that the error is generated by this line:
bottomTtest=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'bottomT',[1 1 1],[length(lon) length(lat) 1 1]);
The error is due to the fact that you've specified 3 start values but 4 count values
bottomTtest=ncread(fullfile(fp,'Temp_Q1(2020).nc'),'bottomT',[1 1 1],[length(lon) length(lat) 1 1]);
% ^^^^^^^ 3 starts
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 counts
just like the error message says: "COUNT has incorrect number of elements (4). The variable has 3 dimensions."

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by