Regrid isosurfaces to 2D arrays

Hi all,
I'm using isosurface to extract an isosurface from a 3D array (I'm providing x,y,z,v and the value of the isosurface that I'm looking for).
After I get the isosurface, I would like to create a gridded 2D array and plot the z values of the isosurface using pcolor (providing x_iso, y_iso, z_iso).
I'm basically trying to do the opposite of what surf does.
I can plot the isosurface, but I don't know how to create the 2D gridded array.
Does anyone know how to do this?
Thanks, Mattia

 Accepted Answer

[x,y,z,v] = flow;
p = isosurface(x,y,z,v,-3);
x = p.vertices(:,1) ;
y = p.vertices(:,2) ;
z = p.vertices(:,3) ;
tri = p.faces ;
trisurf(tri,x,y,z) ;

3 Comments

Thanks KSSV. Is there any way I can obtain a 2D gridded array?
In other words, something that I can plot with pcolor(x,y,Z').
I need it because I have to compare isosurfaces from different datasets. I would like to regrid them to the same grid, and plot the differences between the two isosurfaces.
Hi KSSV, your answer was actually very useful!
I can re-grid x,y and z using griddata. Here is my code:
% Housekeeping
clear all; close all
% Initialiaze figure
figure('units','normalized','outerposition',[0 0 1 0.5])
% Create 3D arrays
dx = 100; dy = 50; dz = 25;
nx = 200; ny = 100; nz = 100;
xs = linspace(0,dx,nx);
ys = linspace(0,dy,ny);
zs = linspace(0,dz,nz);
[X,Y,Z] = meshgrid( xs, ys, zs);
my_array = sin(0.3.*pi+0.4.*pi.*X./dx).*sin(0.3.*pi+0.4.*pi.*Y./dy).*(Z./dz);
% Find isosurface
p = isosurface(X,Y,Z,my_array,0.1);
x = p.vertices(:,1) ;
y = p.vertices(:,2) ;
z = p.vertices(:,3) ;
tri = p.faces ;
% Plot isosurface in 3D
subplot(1,2,1)
trisurf(tri,x,y,z) ;
shading flat
colorbar;
% Re-grid to 2D arrays
[xi,yi] = meshgrid(xs, ys);
zi = griddata(x,y,z,xi,yi);
% Plot isosurface in 2D
subplot(1,2,2)
pcolor(xi,yi,zi);
shading flat
colorbar;
Perfect......!

Sign in to comment.

More Answers (0)

Asked:

on 8 May 2017

Commented:

on 17 May 2017

Community Treasure Hunt

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

Start Hunting!