how plot a correct interpolation with surf plot?
Show older comments
Im using the code:
load A_PRE.mat; %find it attached
load Aelec.mat; %find it attached
figure(1)
X=A_PRE(:,1); Y=A_PRE(:,4); Z=A_PRE(:,5);
[xq,yq]=meshgrid(linspace(min(X),max(X),100),linspace(min(Y),max(Y),100));
zq=griddata(X,Y,Z,xq(:),yq(:),'linear');
[c,h]=contourf(xq,yq,reshape(zq,100,100),'LineStyle','none','LevelStep',100);
hold on
plot(cotas(:,1),cotas(:,2),'k','linewidth',4) %elevation data
hold on
scatter(X,Y,'filled','k')
figure(2)
plot3(Aelec(:,2),Aelec(:,3),Aelec(:,4),'k','linewidth',2);
hold on
scatter3(A_PRE(:,2),A_PRE(:,3),A_PRE(:,4),'filled','k')
hold on
level=A_PRE;
x = level(:,2); y = level(:,3); z = level(:,4); c = level(:,5);
yv = linspace(min(level(:,3)), max(level(:,3)), 100);
zv = linspace(min(level(:,4)), max(level(:,4)), 100);
[Y,Z] = meshgrid(yv, zv);
X = griddata(y,z,x,Y,Z,'cubic');
C = griddata(y,z,c,Y,Z,'cubic');
yA = Aelec(:,3); zA = Aelec(:,4);
in = inpolygon(Y,Z,yA(1:end-1),zA(1:end-1));
Z(in) = nan;
surf(X, Y, Z, 'cdata',C);
shading interp
for plotting the contour:

using surf function and using X and Y coordinates for its location, but when a use the same view of the 2D contour it seems to be interpolated wrong, any ideas about what could be my mistake? how could a I get a contour plot for figure 2 as similar than figure 1.

As you see, the yellow values seems to be affected with the other data using surf plot, any idea about how to obtain the interpolation plot as similar as fig 1? Thanks in advance
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots 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!