plot 3D minimum value of a function

조회 수: 27 (최근 30일)
Zekun Xue
Zekun Xue 2020년 2월 9일
댓글: Star Strider 2020년 2월 10일
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!
Star Strider
Star Strider 2020년 2월 10일
My pleasure!
You, too!

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

카테고리

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