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.

답변 (2개)

David Hill
David Hill 2022년 10월 13일

1 개 추천

g=fimplicit3(@f);
function g = f(x,y,z)
g=1./x.^2 - 1./y.^2 + 1./z.^2;
end

댓글 수: 6

Omar Keele
Omar Keele 2022년 10월 13일
In this case g should not be a surface, I don't understand. Every point in space should have a color assigned to it, the 'value' of the color should be g(x0,y0,z0) for the point (x0,y0,z0).
Maybe the fimplicit3() is not what I am looking for ?
Torsten
Torsten 2022년 10월 13일
fimplicit3 plots the surface for which f(x,y,z) = 0.
For your function, this will be impossible for (x>0 & y<1) since f will always be 1 there.
Omar Keele
Omar Keele 2022년 10월 13일
편집: Omar Keele 2022년 10월 13일
This is not an issue, to draw a line segment in space, take f to be
function f= f(x,y,z)
if x=1 & y=2 & z<3 & z>-3
f= 1
else
f=0
end
end
We can draw isolated points in space if we wish, can't we?
Torsten
Torsten 2022년 10월 13일
I think you have a false impression of what fimplicit plots.
Omar Keele
Omar Keele 2022년 10월 13일
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)

댓글을 달려면 로그인하십시오.

Drc
Drc 2023년 4월 20일

0 개 추천

guys i need this shape code

댓글 수: 1

DGM
DGM 2023년 4월 20일
편집: DGM 2023년 4월 20일
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()

댓글을 달려면 로그인하십시오.

카테고리

제품

릴리스

R2022b

질문:

2022년 10월 13일

편집:

DGM
2023년 4월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by