plot 3D minimum value of a function

27 次查看(过去 30 天)
Hello guys,
Thanks for looking over here.
I'd like to plot a minimum value, more precisely a 'platform' of a function in the 'surf' type of figure something like the graph I attached, no idea how to do it.
I appreciate if you could give me a hand.
Here I attached part of my code about what is my x and y axis:
pn1 = 0:0.1:5;
pn2 = 0:0.1:5;
[Pn1, Pn2] = meshgrid(pn1, pn2);
and what I plot in the figure:
Energy_consumption = Dm.* Pn1 + Tn.* Pn2;
surf(Pn1, Pn2, Energy_consumption);
Thanks you again.
Have a good day.

回答(2 个)

dpb
dpb 2020-2-9
编辑:dpb 2020-2-9
Don't think it could be any easier...look at the following from one of the surf examples:
[X,Y,Z] = peaks(25);
CO(:,:,1) = zeros(25); % red
CO(:,:,2) = ones(25).*linspace(0.5,0.6,25); % green
CO(:,:,3) = ones(25).*linspace(0,1,25); % blue
hS1=surf(X,Y,Z,CO); % first peaks() surface; save handle for later
ZMIN=min(Z(:)); % get the overall minimum Z
hold on % ready axes to add another to it
hS2=surf(X,Y,ZMIN*ones(size(Z))); % and add the plane at the ZMIN height
produces:
  1 个评论
Zekun Xue
Zekun Xue 2020-2-10
Wow, this is new to me, I definitely will try. Thank you very much!
Have a good day!

请先登录,再进行评论。


Star Strider
Star Strider 2020-2-9
Try this:
Dm = 20; % Create Variable
Tn = 30; % Create Variable
pn1 = 0:0.1:5;
pn2 = 0:0.1:5;
[Pn1, Pn2] = meshgrid(pn1, pn2);
Energy_consumption = Dm.* Pn1 + Tn.* Pn2;
surf(Pn1, Pn2, Energy_consumption)
hold on
E_c_min = 40; % Apparently Minimum Is 40
mesh(Pn1, Pn2, ones(size(Pn1))*40) % Create Flat Plane At Minimum
hold off
producing:
1plot 3D minimum value of a function - 2020 02 09.png
  2 个评论
Zekun Xue
Zekun Xue 2020-2-10
Thank you very much! It is very detailed, I will try this in my code.
Have a good day!

请先登录,再进行评论。

类别

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