MATLAB Answers

Info

This question is closed.

How to fill area between contour line and upper bound

8 views (last 30 days)
Maryam Adamzadeh
Maryam Adamzadeh on 27 Mar 2020 at 4:37
Closed: John D'Errico on 27 Mar 2020 at 8:46
How to fill area between the contour line and the upper bound? The code is attached.
clc;
a=2*log(9);
func1 =@(x,W) 1./(1+exp(-a.*(x+log(2))./W)); % function phi-
func2 =@(x,W) 2./(1+exp(-a.*(x)./W)); % function phi-
func3 =@(x,W) (1./(1+exp(-a.*(x)./W))).^2; % function phi-
%-------------
func4 =@(x,W) (1./(1+exp(a.*(x+log(2))./W))); % function phi-
func5 =@(x,W) 1./(1+exp(a.*(x)./W)).^2; % function phi-
%------------------
W1d=2.^[-3.2:0.5:3.2]; % grid points along horizontal direction of plotting
x1d=[-5:0.1:5]; % grid points along vertical direction of plotting
[W,x]=meshgrid(W1d,x1d); % 2D grid points
z=0*x;
im=(x<0);
z(im)=func1(x(im),W(im))-func2(x(im),W(im))+func3(x(im),W(im));
ip=(x>=0);
z(ip)=-func4(x(ip),W(ip))+func5(x(ip),W(ip));
%-----------------
ind=(z<0);
semilogx(W(ind),x(ind),'.')
hold on
[C,h]=contour(W,x,z,[0 ,0],'k')
h.LineWidth = 3
clabel (C, h);
set(gca,'xtick',2.^[-3:3])
set(gca,'fontsize',14)

  1 Comment

Mohammad Sami
Mohammad Sami on 27 Mar 2020 at 7:12
You can use either fill or patch to make a colored region.

Answers (0)

Sign in to answer this question.