3D plot a function f(x,y,z)

36 visualizaciones (últimos 30 días)
Omar Keele
Omar Keele el 13 de Oct. de 2022
Editada: DGM el 20 de Abr. de 2023
I have a function of the coordinates x,y and z like the following :
function f= f(x,y,z)
if (x>0) & (y<1) % this is just an example, do whatever you want with the variables
f= 1;
else
f= x-y+2*z;
end
end
That I want to plot like by using the fimplicit3() function :
syms f(x,y,z)
f(x,y,z) = x^2 + y^2 - z^2;
fimplicit3(f)
The problem is fimplicit3 deals with the symbolic variables but fails to take as argument a function that I 'manually' specified above.
Is there another way to plot such a function ?
I just wanna draw some balls in space.

Respuestas (2)

David Hill
David Hill el 13 de Oct. de 2022
g=fimplicit3(@f);
function g = f(x,y,z)
g=1./x.^2 - 1./y.^2 + 1./z.^2;
end
  6 comentarios
Omar Keele
Omar Keele el 13 de Oct. de 2022
I mentioned the fimplicit to illustrate, do you know a matlab command to do this ? Maybe scatter3D?
Something that plot values of f(x,y,z) with different colors, the space should be filled ! (or maybe empty if the value is 0)

Iniciar sesión para comentar.


Drc
Drc el 20 de Abr. de 2023
guys i need this shape code
  1 comentario
DGM
DGM el 20 de Abr. de 2023
Editada: DGM el 20 de Abr. de 2023
Start a new question at the "Ask" link at the top of the page. Include enough information so that other people know specifically what you want. Considering that specific details were intentionally omitted from the image, I have to wonder why you're making it difficult.
Otherwise, see cylinder(), patch(), surf()

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by