Limit a CONTOURF plot under a line
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I want to limit the contour plot of u under the black curve h wich is a function of x: h=h(x). Indeed, u is a function of x and h: u=u(x,h). How may I do it? Thanks in advance for your help. Until now, I wrote the following code:
yyaxis left
plot(x,B)
xlabel("dimensional streamwise")
ylabel("magnetic field")
yyaxis right
plot(x,h)
ylabel("dimensional interface")
grid on
hold on
[X,Y]= meshgrid(x,h);
U=ones(1000).*u;
contourf(X,Y,U,'edgecolor','none')
hold on
colorbar
% dimensions of the variables
% x 1000x1
% B 1000x1
% h 1000x1
% u 1000x1
% U 1000x1000
Regards,
Andrea

댓글 수: 0
답변 (1개)
DGM
2021년 8월 11일
Consider:
numpoints = [1000 1000]; % [x y]
% build boundary curve
x = linspace(-2,2,numpoints(1));
y = 4*x-x.^3;
% build 2D map
y2 = linspace(-4,4,numpoints(2)).';
z = sin(x*2).*sin(y2*2);
% set unwanted map data to NaN
z(y2>y) = NaN;
% pcolor is probably what you're after
pcolor(x,y2,z)
% or you could use contourf if that's really what you want
%contourf(x,y2,z,'edgecolor','none')
hold on
% using a thick line helps hide the ragged edge
h = plot(x,y,'k','linewidth',3);
colormap(summer)
shading flat
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
