plot 3D minimum value of a function
27 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
dpb
on 9 Feb 2020
Edited: dpb
on 9 Feb 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:
Star Strider
on 9 Feb 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:
2 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!