plot 3D minimum value of a function

26 visualizaciones (últimos 30 días)
Zekun Xue
Zekun Xue el 9 de Feb. de 2020
Comentada: Star Strider el 10 de Feb. de 2020
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.

Respuestas (2)

dpb
dpb el 9 de Feb. de 2020
Editada: dpb el 9 de Feb. de 2020
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 comentario
Zekun Xue
Zekun Xue el 10 de Feb. de 2020
Wow, this is new to me, I definitely will try. Thank you very much!
Have a good day!

Iniciar sesión para comentar.


Star Strider
Star Strider el 9 de Feb. de 2020
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 comentarios
Zekun Xue
Zekun Xue el 10 de Feb. de 2020
Thank you very much! It is very detailed, I will try this in my code.
Have a good day!
Star Strider
Star Strider el 10 de Feb. de 2020
My pleasure!
You, too!

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by