Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Plot contours at a level I wish

1 visualización (últimos 30 días)
David Arnold
David Arnold el 15 de Mayo de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
All,
I have the following code:
close all
clc
N=linspace(10,110,40);
P=linspace(10,70,40);
[N,P]=meshgrid(N,P);
a=0.4;
b=0.01;
c=0.005;
d=0.3;
d/c
a/b
H=c*N-d*log(N)-a*log(P)+b*P;
f=mesh(N,P,H);
set(f,'EdgeAlpha',0.6)
hold on
contour3(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]);
contour(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]);
box on
xlabel('N-axis')
ylabel('P-axis')
rotate3d
commandwindow
I'd like to set the second set of contours at the bottom of the plot, at z=-2.5. Can someone show me how to do that?
Thanks
D.

Respuestas (2)

Teja Muppirala
Teja Muppirala el 15 de Mayo de 2012
Here's one idea.
First change this line:
contour(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]);
to this (in order to get the handle of the contour object):
[~,h] = contour(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]);
And add this at the end: (to process each contour in series)
kids = get(h,'children');
set(gca,'zlimmode','manual');
for n = 1:numel(kids)
set(kids(n),'zdata', min(zlim)+zeros(size(get(kids(n),'ydata'))))
end

David Arnold
David Arnold el 15 de Mayo de 2012
Excellent! May I ask one more question? When I change the paper size and position, then rotate the view, the axis labels (in this case "Prey" and "Predator") always wind up in a poor position. How can I write code to move them close to the center of the axes after such a rotation of the view?
close all
clc
N=linspace(10,110,40);
P=linspace(10,70,40);
[N,P]=meshgrid(N,P);
a=0.4;
b=0.01;
c=0.005;
d=0.3;
d/c
a/b
H=c*N-d*log(N)-a*log(P)+b*P;
f=mesh(N,P,H);
set(f,'EdgeAlpha',0.6)
hold on
contour3(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]);
[c,h]=contour(N,P,H,[-2,-1.99,-1.98,-1.97,-1.96]);
kids = get(h,'children');
set(gca,'zlimmode','manual');
for n = 1:numel(kids)
set(kids(n),'zdata', min(zlim)+zeros(size(get(kids(n),'ydata'))))
end
axis tight
box on
xlabel('Prey')
ylabel('Predator')
title('Closed periodic solutions.')
view(42,32)
set(gcf,'PaperSize',[4,3])
set(gcf,'PaperPosition',[0,0,4,3])
saveas(gcf,'closed','pdf')

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by