如何平滑对应于nan的等高线图中的边缘

时间:2016-02-23 00:35:11

标签: matlab

This is the link to the dataset. 我有这个轮廓图,边缘有点粗糙。我的问题是,如何平滑这些边缘,这些边缘对应于Nan。我用Nan填充Z矩阵,以便删除不需要的值。

我还想问一下,为什么阴影平坦和interp不能在这个轮廓上工作。

我已将阴影设置为平坦,在Matlab2013b中我得到了合适的平面图但在Matlab 2014b和2015b中我得到了这个数字。

MATLAB 2015b

enter image description here

MATLAB 2013b enter image description here

如何在Matlab 2015b中获得完美的网格图,我在文档中检查了阴影选项,只有3个刻面,interp和flat。

阴影平面在2013b中工作,但在后续版本中不起作用。有人可以告诉我为什么会这样吗?

这是我现在使用的示例代码:

clear all; close all; clc;

load temperature.txt;

time = temperature(:,1);               % This column contains the time
x = temperature(:,2);                  % This column contains the x values.
temperature_system = temperature(:,3); % This column contains the temperatures.

% Rejecting the outliers
pos = (temperature_system > prctile(temperature_system,97));
time(pos) = [];
x(pos) = [];
temperature_system(pos) = [];

X1 = [time x];


F = scatteredInterpolant(X1,temperature_system);
x1 = linspace(min(x),max(x),100);
x2 = linspace(min(time),max(time),100);
[X,Y] = meshgrid(x2,x1);
Z = F(X,Y);

% Is the data below the criteria for all points in space at a specific time
emptyTime = all(Z<10,1);
emptySpace = all(Z<10,2);
[emptyTime, emptySpace] = meshgrid(emptyTime, emptySpace);
Z(emptyTime | emptySpace) = nan;

% Replacing the remaining zeros with nan
pos = find(Z<1);
Z(pos) = nan;
f1 = figure(1);
%set(f1,'renderer','zbuffer');

%surf(X,Y,Z);

[C,h] = contourf(X,Y,Z, 'Linestyle', 'none');
shading flat;
colormap(jet);
q = colorbar;
set(q,'direction','reverse');
q.Label.String = 'Temperature';


xlabel('Time (ps)','FontSize', 16, 'FontWeight', 'bold',...
   'FontName', 'Helvetica', 'Color', 'Black');
ylabel('Length of box (A)','FontSize', 16, 'FontWeight', 'bold',...
    'FontName', 'Helvetica', 'Color', 'Black');

set(gca,'LineWidth',3,'TickLength',[0.02 0.02]);
set(gca,'XMinorTick','on');
set(gca,'YMinorTick','on','XTicksBetween', 5);
set(gca,'FontSize',12,'FontName','Helvetica');

1 个答案:

答案 0 :(得分:1)

如果没有您的数据,很难测试问题。我通过LineStyle属性删除了这些行:

enter image description here

代码:

Z = peaks(20);
subplot(2,1,1);
contourf(Z,10);
colorbar;
subplot(2,1,2);
contourf(Z,10, 'LineStyle', 'none');
colorbar;