필터 지우기
필터 지우기

How can I prevent my graph from extrapolating data?

조회 수: 3 (최근 30일)
David Hallett
David Hallett 2015년 7월 17일
편집: Walter Roberson 2015년 7월 17일
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);

채택된 답변

Eric Pahlke
Eric Pahlke 2015년 7월 17일
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);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by