How can I prevent my graph from extrapolating data?

4 views (last 30 days)
I am using the 'scatteredinterpolant' command to plot a set of data and am having an issue with getting the graph to plot smooth lines. Also the data seems to be extrapolating showing values much higher than any in the data set. How can I get the graph to smooth out and remove the transition zone in the middle?
cla
F = scatteredInterpolant(CollarPlanE,CollarPlanN,AverageofMWDS_prate,'linear');
[xx,yy]=meshgrid(CollarPlanE,CollarPlanN);
zz = F(xx,yy);
[~, hC] = contourf(xx,yy,zz,10);
set(hC,'LineStyle','none');
colormap jet
set(gcf,'color','w');
c = colorbar('Fontsize',16,'FontName', 'Arial');
c.Label.String = 'Penetration Rate(m/min)';
title('Average Penetration Rate Rd 48a Bench 11160','Fontsize',20,...
'FontWeight','bold','FontName', 'Arial');
xlabel('Grid E','FontSize',16,'FontName', 'Arial');
ylabel('Grid N','FontSize',16,'FontName', 'Arial');
xlim([7565 7685]);
ylim([4905 4980]);
hold on
x = CollarPlanE;
y = CollarPlanN;
scatter(x,y,'MarkerEdgeColor',[0 .5 .5],...
'MarkerFaceColor',[1 0 0],...
'LineWidth',1.5);
a = RowLabels;
b = num2str(a);
c = cellstr(b);
dx = 1; dy = -3; % displacement so the text does not overlay the data points
text(x+dx, y+dy, c);

Accepted Answer

Eric Pahlke
Eric Pahlke on 17 Jul 2015
The problem is that you are using meshgrid() on CollarPlanE and ...N directly. Since those vectors are not sorted, the mesh grid you're creating isn't sorted either, causing the strange twisting in the graph.
Instead, define an equally spaced and sorted vectors for x and y that you want to plot over, then do the meshgrid on those.
Also, as an aside, when you paste your code in the question, highlight all the code and click the "{}Code" button to make sure the formatting is preserved.
cla
F = scatteredInterpolant(CollarPlanE,CollarPlanN,AverageofMWDS_prate,'linear');
x = linspace(min(CollarPlanE),max(CollarPlanE),101);
y = linspace(min(CollarPlanN),max(CollarPlanN),101);
[yy,xx]=meshgrid(y,x); zz = F(xx,yy);
[~, hC] = contourf(xx,yy,zz,10);
set(hC,'LineStyle','none');
colormap jet
set(gcf,'color','w');
c = colorbar('Fontsize',16,'FontName', 'Arial');
c.Label.String = 'Penetration Rate(m/min)';
title('Average Penetration Rate Rd 48a Bench 11160','Fontsize',20,...
'FontWeight','bold','FontName', 'Arial');
xlabel('Grid E','FontSize',16,'FontName', 'Arial');
ylabel('Grid N','FontSize',16,'FontName', 'Arial');
xlim([7565 7685]); ylim([4905 4980]);
hold on
x = CollarPlanE;
y = CollarPlanN;
scatter(x,y,'MarkerEdgeColor',[0 .5 .5],...
'MarkerFaceColor',[1 0 0],...
'LineWidth',1.5);
a = RowLabels;
b = num2str(a);
c = cellstr(b);
dx = 1;
dy = -3; % displacement so the text does not overlay the data points text(x+dx, y+dy, c);

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!