MATLAB: I can’t make contour while z value is already knew

data processinggeophysics

Hello guys, I have some trouble in here. i want to try process my magnetic data with matlab. But, when i want to draw it like in a map, i can't figure what script is going to use. Here my data, X Y Magnetic Value
0 0 -330.6025
5 0 -36.47359375
10 0 172.3079687
15 0 -290.2571875
0 5 -1041.775469
5 5 -3180.319063
10 5 -2489.383125
15 5 -719.045
0 10 -714.6904687
5 10 206.0775
10 10 -1194.575625
15 10 -1656.451719
Also this is my script,
x=magnetik(:,1);
y=magnetik(:,2);
xx=vec2mat(x,34);
yy=vec2mat(y,34)
z=magnetik(:,3);
zz=vec2mat(z,34)
surf(xx,yy,zz)
contour(xx,yy,zz)

Best Answer

Let A be your (x,y,z) data.....(a three column matrix)
x = A(:,1) ;
y = A(:,2) ;
z = A(:,3) ;
xi = unique(x) ;
yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,length(yi),length(xi)) ;
surf(X,Y,Z)
Now you can call contour on X, Y and Z.
Related Question