MATLAB Answers

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

3 views (last 30 days)
Rajesh Sahu
Rajesh Sahu on 21 Jan 2020
Commented: Rajesh Sahu on 21 Jan 2020
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 Comments

Jakob B. Nielsen
Jakob B. Nielsen on 21 Jan 2020
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));

Sign in to comment.

Answers (0)

Sign in to answer this question.

Tags