while running this code i am getting this error (Error using pcolor (line 61) Matrix dimensions must agree), can anybody help me regarding this.

clc
clear
clear all
f='test1final.nc';
ncdisp(f);
lat1=ncread(f,'xlat');
lon1=ncread(f,'xlong');
temp=ncread(f,'t2');
for i = 1:size(temp,4)
mymap=pcolor(lon1,lat1,temp(:,:,:,i));
shading interp
end

2 个评论

The error tells you the "why"; your matrix dimensions are not the same. Check the dimenions; if for example lon1 is 1x10 and lat1 is 1x11 and temp is 10x10x5, there is your problem; lat1 has a different dimension than the others.
Another issue is that you seem to call a 4D matrix temp. Is it maybe only 3D, so your code should say (remove one :)
pcolor(lon1,lat1,temp(:,:,i));

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by