How to interpolate and build a 4D hamburger?

I solved the octave heat equation through finite difference and created the following 3D plot with the dotted colors corresponding to the temperatures in each element of my 3D hamburger.

My computing resources are limiting the resolution at which I can solve my burger. So the only way to get the plot I want is to make my scattered dots into huge blobs of color, and that looks pretty good.

[x,y,z] = meshgrid(1:nx,1:ny,1:nz)                       % Defines a grid to plot on
scatter3(x(:), y(:), z(:), 40, burgermatrix(:), 's', 'filled')% Point color=value

      

The perfect burger

What I want is a beautiful gorgeous smooth rectangular prism:

Prism

So, I suppose I need to interpolate somehow between the 3D points I have. Can anyone help me figure out how to do this?

+3


source to share


1 answer


I may be missing something obvious, but here's an example from an octave help slice

:

[x, y, z] = meshgrid (linspace (-8, 8, 32));
v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
slice (x, y, z, v, [], 0, []);
[xi, yi] = meshgrid (linspace (-7, 7));
zi = xi + yi;
slice (x, y, z, v, xi, yi, zi);
shading interp; %addition by me

      

Isn't that what you need? You have your own grid ( x

, y

, z

), your decisions ( T

), so you just need to draw it along the thread [0 0 1]

, etc. Something like

[xi yi]=meshgrid(unique(x),unique(y));
slice (x, y, z, T, xi, yi, max(z(:))*ones(size(xi)));

      



and the same for cuts along the other two axes. (Obviously, the calls unique

should be replaced with the vectors you already have, from which you created the 3D mesh in the first place.)

NOTE. ... By the way, you should really consider changing the default colormap ( jet

). Yesterday I was enlightened by a colleague about the color palette viridis

made by SciPy people, see this post and video link for example . Their reasoning is stunning, and their bell tower is beautiful. This should define it: viridis , although I haven't tried it myself yet.

(If it wasn't for jet

, I would tell you that your temperature profile appears to be strong 1d. Do you have periodic boundary conditions along vertical walls and uniform (i.e. constant) boundary conditions along the horizontal te?)

0


source







All Articles