# How to use contourf to plot a mesh not generated in matlab, i.e. imported mesh coordinates from abaqus. The issue is that coordinates are not sequential.

31 views (last 30 days)

Show older comments

##### 0 Comments

### Answers (2)

Star Strider
on 7 Jul 2024 at 21:09

It would help tto have your data.

Since there are (x,y,z) coordinates (there can be duplicates), I would use the scatteredInterpolant function to create an interpolant, and then use either ndgrid or meshgrid tto create the relevant argument matrices using the ‘x’and ‘y’.vectors to define them.

There are several examples on MATLAB Answers using that approach, that create column vectors for ‘x’, ‘y’ and ‘z’ to use with scatteredInterpolant,.and then generate the ‘z’ matrix from the argument matrices. Then use surf or surfc to plot them.

.

##### 4 Comments

Star Strider
on 8 Jul 2024 at 12:46

This sort of works, however it takes 605.3 seconds to complete and about as much time to render the surface plots. It fails, because it fills (interpolates) the voids areas. I do not see any way to correct for that.

imshow(imread('boundary conditions.jpg'))

LD = load('plotdata.mat');

plot = LD.plot;

x = plot(:,1);

y = plot(:,2);

z = plot(:,3);

figure

scatter3(x, y, z, 5, z, 'filled')

colormap(turbo)

% return

tic

xv = linspace(min(x), max(x), size(plot,1));

yv = linspace(min(y), max(y), size(plot,1));

F = scatteredInterpolant(x, y, z);

[X,Y] = ndgrid(xv, yv);

Z = F(X,Y);

figure

surfc(X, Y, Z, 'EdgeColor','none')

T = delaunay(X, Y);

figure

trisurf(T, X, Y, Z, 'EdgeColor','k', 'LineWidth',0.2)

toc

This also ended up crashing my computer.

.

Walter Roberson
on 7 Jul 2024 at 19:56

Edited: Walter Roberson
on 7 Jul 2024 at 20:02

Perhaps try

Also, possibly it would help to use https://www.mathworks.com/matlabcentral/fileexchange/27830-mesh2tetra

(List order is numeric)

##### 2 Comments

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!