create an interpolated grid

3 visualizaciones (últimos 30 días)
wassim boulala
wassim boulala el 3 de Sept. de 2020
Comentada: wassim boulala el 4 de Sept. de 2020
Hi!
i have created with a simple line code a grid from a table of tree colums (X,Y cartesian coordinates) Z altitudes .i want to creat an interpolated grid (interpolate the Z values) with a step (delta x and delta y of 20). i tried this but it doesn't works . can you help me please?
clear;
format long e
%open file xyz
T=readtable('points.txt');
A=T{:,:};
X=A(:,1);
Y=A(:,2);
Z=A(:,3);
min_x=min(X);
max_x=max(X);
min_y=min(Y);
max_y=max(Y);
n=length(X);
[XX,YY] = meshgrid(linspace(min(X),max(X),100),linspace(min(Y),max(Y),72));
%first grid
ZZ = griddata(X,Y,Z,XX,YY);
% new interpolated grid
[xi,yi]=meshgrid(min_x:20:max_x,min_y:20:max_y);
bathimtry=interp2(X,Y,ZZ,xi,yi);
lonx=min_x:20:max_x;
laty=min_y:20:max_y;
%surf(XX,YY,ZZ);
%ZZ(ZZ>0)=nan;
figure(1)
%pcolor(XX,YY,ZZ),shading interp ,colorbar;
pcolor(lonx,laty,bathimtry),shading flat ,colorbar;
saveas(gcf,'bat_fine','eps');

Respuesta aceptada

KSSV
KSSV el 4 de Sept. de 2020
% new interpolated grid
lonx=min_x:20:max_x;
laty=min_y:20:max_y;
[Xi,Yi]=meshgrid(lonx,laty);
bathymetry=interp2(XX,YY,ZZ,Xi,Yi);
%surf(XX,YY,ZZ);
%ZZ(ZZ>0)=nan;
figure(1)
%pcolor(XX,YY,ZZ),shading interp ,colorbar;
pcolor(Xi,Yi,bathymetry),shading flat ,colorbar; % if error transpose bathymetry and see
saveas(gcf,'bat_fine','eps');
Also you can striaght away try this:
clear;
format long e
%open file xyz
T=readtable('points.txt');
A=T{:,:};
X=A(:,1);
Y=A(:,2);
Z=A(:,3);
min_x=min(X);
max_x=max(X);
min_y=min(Y);
max_y=max(Y);
n=length(X);
% new interpolated grid
lonx=min_x:20:max_x;
laty=min_y:20:max_y;
[Xi,Yi]=meshgrid(lonx,laty);
bathymetry=interp2(X,Y,Z,Xi,Yi);
ZZ = griddata(X,Y,Z,Xi,Yi);
%surf(XX,YY,ZZ);
%ZZ(ZZ>0)=nan;
figure(1)
%pcolor(XX,YY,ZZ),shading interp ,colorbar;
pcolor(lonx,laty,bathymetry),shading flat ,colorbar; % if error transpose the bathymetry
saveas(gcf,'bat_fine','eps');
  1 comentario
wassim boulala
wassim boulala el 4 de Sept. de 2020
i think that works , thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Orange en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by