Meshgrid for 3 variables
16 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
KSSV
2021-5-3
Read about surf.
5 个评论
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!