Plot a function of three variable

Hey, I want to plot a function of three variables. Consider that I have a function like f(x,y,z)=x^2+y^2+z^2-3xyz, I want a surface plot of this function. How can I do that? Thanks!

답변 (1개)

KSSV
KSSV 2019년 1월 16일

2 개 추천

f = @(x,y,z) x.^2+y.^2+z.^2-3*x.*y.*z ;
x = linspace(-1,1) ;
y = linspace(-1,1) ;
z = linspace(-1,1) ;
[X,Y,Z] = ndgrid(x,y,z) ;
F =f(X,Y,Z) ;
figure
hold on
for i = 1:100
surf(X(:,:,i),Y(:,:,i),Z(:,:,i),F(:,:,i)) ;
end

댓글 수: 3

Md Borhan Mia
Md Borhan Mia 2019년 1월 16일
Thanks for the reply, KSSV. But, I want a 3D surface plot. How can I get that?
syms X Y Z
f = @(x,y,z) x^2 + y^2 + z^2;
surff = f(X,Y,Z);
fimplicit3(surff)
@Md Borhan Mia you can use view to visualize a 3D plot
f = @(x,y,z) x.^2+y.^2+z.^2-3*x.*y.*z ;
x = linspace(-1,1) ;
y = linspace(-1,1) ;
z = linspace(-1,1) ;
[X,Y,Z] = ndgrid(x,y,z) ;
F =f(X,Y,Z) ;
figure
hold on
for i = 1:100
surf(X(:,:,i),Y(:,:,i),Z(:,:,i),F(:,:,i)) ;
end
view(45,45)

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

카테고리

제품

릴리스

R2018a

태그

질문:

2019년 1월 16일

댓글:

2023년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by