Error in internal.m​apgraph.Co​ntourGroup​>oneVertex​Patch

4 vues (au cours des 30 derniers jours)
Szabó-Takács Beáta
Szabó-Takács Beáta le 24 Juin 2016
Commenté : Walter Roberson le 27 Juin 2016
Dear All, I have a 2D matrix dif1 where size(dif1,1) = 1 and size(dif1,2)=longitude*latitude (464*201). I divided its values into 8 categories by:
diff=repmat(NaN,1,length(dif1));
diff(find(9 > dif1))=1;
diff(find(13.2 > dif1 & dif1 >=9))=2;
diff(find(17.3 > dif1 & dif1 >=13.2))=3;
diff(find(21.5>dif1& dif1 >= 17.3))=4;
diff(find(25.7>dif1& dif1 >= 21.5))=5;
diff(find(29.8>dif1& dif1 >= 25.7))=6;
diff(find(34>dif1& dif1 >= 29.8))=7;
diff(find(dif1 >= 34))=8;
and
IU=permute(reshape(diff, 1, 464, 201, [ 1 2 3]));
IU2=permute(IU,[3 2 1]);
The minimum value of diff is 1 and the maximum one is 8. I tried to create a contour plot by:
worldmap('Europe');
load coast;
plotm(lat, long, 'k');
clear lat long;
lat=load(lat.mat);
contourfm(lat,lon,IU2,7);
contourcmap('jet','Colorbar', 'on', 'Location', 'horizontal')
but I got the following error:
Index exceeds matrix dimensions.
Error in internal.mapgraph.ContourGroup>oneVertexPatch (line 1230)
p = patch('Parent',ax,'XData',x(1),'YData',y(1),'ZData',z(1), ...
Error in internal.mapgraph.ContourGroup>addLineCData (line 1169)
p(k) = oneVertexPatch(ax, hLine(k));
Error in internal.mapgraph.ContourGroup/refresh (line 505)
addLineCData(h)
Error in contourm (line 116)
refresh(h)
Error in contourfm (line 36)
contourm(varargin{:},'Fill','on','DefaultLineColor','black');
I do not understand what the matter is. Could someone suggest me a solution?

Réponses (1)

Walter Roberson
Walter Roberson le 24 Juin 2016
In order for your code
clear lat long;
lat=load(lat.mat);
to work, you would need to have defined a class named lat or have used an import statement to bring lat into scope from Java, to allow the lat.mat to refer to a method of lat . The clear removes the possibility that lat is a variable at that statement, and if lat were a function at that point, it would not be permitted in MATLAB to directly deference the result of the function as if it were a structure. I would suggest to you that you did not post your actual code, and that your actual code has
lat=load('lat.mat');
with 'lat.mat' as a quoted string that indicates which file is to be loaded.
The output of load() when assigned to a variable is a structure array of length 1, with one field for each variable stored in the .mat file. Given the names, it is probable that at that after that statement, lat is a structure with a field named lat that contains the actual information that you want to use. The counter call then fails because it is not expecting a scalar structure as a data parameter.
I suggest changing your code to something like,
data = load('lat.mat');
lat = data.lat;
  2 commentaires
Szabó-Takács Beáta
Szabó-Takács Beáta le 27 Juin 2016
I tried it but it does not help. I restart my matlab and I loaded my data and renamed them by:
load('lat.mat')
>> load('lon.mat')
>> latitude=double(lat);
>> longitude=double(lon);
>> load('IU2.mat');
>> worldmap('Europe');
load coast;
plotm(lat, long, 'k');
clear lat long;
contourfm(latitude,longitude,IU2,7);
contourcmap('jet','Colorbar', 'on', 'Location', 'horizontal')
But I got the same error.
Walter Roberson
Walter Roberson le 27 Juin 2016
What shows up for
size(latitude)
size(longitude)
size(IU2)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Mapping Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by