help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sliceomatic for Octave? Plotting "slices" of f(x, y, z)


From: lcocea
Subject: Sliceomatic for Octave? Plotting "slices" of f(x, y, z)
Date: Sat, 5 Aug 2017 20:40:04 -0700 (PDT)

Anybody know where to find a tool like Sliceomatic
(https://www.mathworks.com/matlabcentral/fileexchange/764-sliceomatic) for
Octave? Any help will be greatly appreciated. I couldn't find anything
similar on Google so yesterday afternoon I wrote some simple code for my
project to visualize "slices" of a function f(x, y, z) using scatter3. 

The parameters of the 3d plotting function are the x, y, z, and f vectors,
and the number of slices n. The algorithm divides the max(f) - min(f)
interval into n - 1 intervals, or "slices". Note that the term "slice" here
is different from that used in Sliceomatic. It then creates n subplots, one
per "slice", and assigns to each subplot only the values of f that fall
within the corresponding "slice".

Here are a few screenshots:

This is a 4-slice plot of the normal distribution function f(x, y, z) =
exp(-(x^2 + y^2 + z^2)): 
<http://octave.1599824.n4.nabble.com/file/n4684342/demo_normal.png> 
The rainbow color map was used, so blue and purple shades in the fourth
slice point to the local maximum.

This is 3-slice plot of the "quadratic" function f(x, y, z) = x^2 + y^2 -
z^2:
<http://octave.1599824.n4.nabble.com/file/n4684342/demo_multipit1.png> 
The red shades in the first slice indicate the proximity of one of the two
local minima.

The following two screenshots show the function f(x, y, z) = sin(x)/x +
sin(y)/y + sin(z)/z:
<http://octave.1599824.n4.nabble.com/file/n4684342/demo_multipit2_b.png> 
<http://octave.1599824.n4.nabble.com/file/n4684342/demo_multipit2_a.png> 
The second one is a "zoom in" of the first one where the x, y, and z axis
ranges are [-5, 5] instead of [-10, 10].

Here is the code of the first function to play with:

----

----

Here is the code of the myScatter3d function:

----

----

Feel free to change the number of colors (currently 512) and the color map
(currently "rainbow") as you like.

As I think that even a grade 6 could write this kind of code these days, the
code above is free to use as you see fit and in any kind of project,
commercial or non-commercial. Cheers!



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Sliceomatic-for-Octave-Plotting-slices-of-f-x-y-z-tp4684342.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]