Meshgrid for 3 variables

조회 수: 12 (최근 30일)
Sanket Sutar
Sanket Sutar 2021년 5월 3일
댓글: Sanket Sutar 2021년 5월 5일
Hello, I have a question. I am trying to solve a optimization problem but my function has 3 variables and I am not sure how to plot a 3d diagram of 3 variable function.
  댓글 수: 1
VBBV
VBBV 2021년 5월 3일
Use plot3 function

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

채택된 답변

KSSV
KSSV 2021년 5월 3일
Read about surf.
  댓글 수: 5
KSSV
KSSV 2021년 5월 4일
m = 10 ;
x = linspace(0,1,m) ;
y = linspace(0,1,m) ;
z = linspace(0,1,m) ;
[x,y,z] = meshgrid(x,y,z) ;
f = (x+5).^2+(y+8).^2+(z+7).^2+(2.*x.^2.*y.^2)+(4.*x.^2.*z.^2);
figure
hold on
for i = 1:size(f,3)
surf(x(:,:,i),y(:,:,i),z(:,:,i),f(:,:,i)) ;
end
view(3)
Read about slice.
Sanket Sutar
Sanket Sutar 2021년 5월 5일
Thank you so much for your help !!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by