# 3D color map of F=F(x,y,z) where data is given as a 2D array of the form [x y z F]

11 views (last 30 days)

Show older comments

##### 2 Comments

### Accepted Answer

Karim
on 3 Jan 2023

Edited: Karim
on 3 Jan 2023

Hello , you can create those plots both for both 2D and 3D elements using the patch command. Essentially you need a connecitivty matrix (i.e. the faces of the patch) which you have since these are the faces of the elements used in the mesh. Hense next to the coordindates of the nodes, you also need the connecivity. If you can share a set of sample data (i.e. the mesh, the nodes and the value for plotting) i can adjust the example to meet you data. You can use the paperclip symbol to attach data (of a small example) to you question.

See below for a demonstration of the concept:

% the data here will differ depending on the used FE package, these are

% outputs from ansys i used as a demo in another matlab answer

% this file contains the xyz coordinates of the grid points

coordinates = readmatrix("coordinates.csv");

% this file contains the deformation values, which we will use to create the 'F' variable

displacements = readmatrix("displacements.csv");

% let's use the magnitude of the deformation as color

F = sqrt( sum(displacements(:,2:end).^2,2));

% this file containts the node conectivity (i.e. the nodes that make up the elements)

nodes = readmatrix("nodes.csv");

% now create the plot

figure

patch('Faces',nodes(:,2:end),'Vertices',coordinates(:,2:end),'FaceVertexCData',F,'FaceColor','interp',...

'EdgeAlpha',0.15) % put the edge alpha to 0 if you went to hide the element edges

view([-15 45])

axis equal

colormap jet

colorbar

title("Deformed")

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!