Matlab, how to make a smooth contour plot?

I want to present data with 2 variables in 2D format. The value is represented by color, and 2 variables by axis 2. I use the contour function to build my data:

clc; clear;

load('dataM.mat')

cMap=jet(256); %set the colomap using the "jet" scale
F2=figure(1);
[c,h]=contourf(xrow,ycol,BDmatrix,50);
set(h, 'edgecolor','none');

xlim([0.0352 0.3872]);
ylim([0.0352 0.3872]);

colormap(cMap);
cb=colorbar;
caxis([0.7 0.96]);
% box on;
hold on;

Both xrow and ycol are 6x6 matrices representing the coordinates. BDmatrix is ​​a 6x6 matrix representing the relevant data. However, I get the following:

enter image description here

The following are the xrow and yrow matrices:

enter image description here

The following are BDmatrix matrices:

enter image description here

Is it possible that the color of the outline will change smoothly, and not appear as straight lines connecting data points? The problem with this figure is the rough granularity, which is not attractive. I tried replacing contourf with imagec, but it doesn't seem to work. I am using MATLAB R2015b.

+4
2

.

newpoints = 100;
[xq,yq] = meshgrid(...
            linspace(min(min(xrow,[],2)),max(max(xrow,[],2)),newpoints ),...
            linspace(min(min(ycol,[],1)),max(max(ycol,[],1)),newpoints )...
          );
BDmatrixq = interp2(xrow,ycol,BDmatrix,xq,yq,'cubic');
[c,h]=contourf(xq,yq,BDmatrixq);

"" newpoints.

Graph example

, . 10. 50:

 [c,h]=contourf(xq,yq,BDmatrixq,50);

Approximate fine

3D-surf . . , .

 f = figure;
 ax = axes('Parent',f);
 h = surf(xq,yq,BDmatrixq,'Parent',ax);
 set(h, 'edgecolor','none');
 view(ax,[0,90]);
 colormap(Jet);
 colorbar;

Sample is smooth

1: . , , BDmatrix ( , ). BDmatrix , .

2: xrow yrow ( ), min-max-extract, .

3: , xrow ycol ndgrid. , . interp2 meshgrid, griddedInterpolant:

[xq,yq] = ndgrid(...
            linspace(min(min(xrow,[],1)),max(max(xrow,[],1)),newpoints ),...
            linspace(min(min(ycol,[],2)),max(max(ycol,[],2)),newpoints )...
          );
F = griddedInterpolant(xrow,ycol,BDmatrix,'cubic');
BDmatrixq = F(xq,yq);
+6

, pcolor shading, . , , :

tmp = peaks(80);

figure;
subplot(1,2,1)
pcolor(tmp)
shading flat
title 'Uninterpolated'
subplot(1,2,2)
pcolor(tmp)
shading interp
title 'Interpolated'

enter image description here

-1

Source: https://habr.com/ru/post/1680381/


All Articles