Roberto Ruggeri
Roberto Ruggeri

Reputation: 79

Stress 3D Surface Plot in Matlab

I wrote a finite element program in Matlab which calculates the stresses of a 3D plate. Now I would like to print these stresses but it is really hard to do for me. For each gauss point I can have the XYZ associated coordinate with its stress. How can I do a plot like the ones I see in the FE software in Matlab? Currently what I can do is to plot a colour for the XYZ point assigning a colour range to the stresses. My result is a scatter plot. I would like to have something like this enter image description here

Thank you for your help!

Upvotes: 1

Views: 332

Answers (1)

pho
pho

Reputation: 25479

Matlab has a surf(X, Y, Z, C) function that can take a color argument (C). Without the C argument, it uses the Z value to color the surface.

[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
C = X.*Y;
surf(X,Y,Z,C)

The color is set using your active colormap.

If you want more control over the colors, C can also be a MxNx3 array where the C(M, N, :) gives the RGB value of the color at the MxNth point.

Upvotes: 1

Related Questions