Contour plot on a surface plot

조회 수: 31 (최근 30일)
Tomas Altea
Tomas Altea 2021년 11월 19일
답변: KSSV 2021년 11월 22일
Hi everyone,
I have imported a 2D surface comsol matrix data in a three-column format (x-coordinate, y-coordinate and color data) and I've plotted it using this code:
A = load('Comsol_surf.txt');
x = A(:,1);
y = A(:,2);
z = A(:,3);
tri = delaunay(x,y);
figure
h = trisurf(tri,x,y,z,'EdgeColor','none');
axis vis3d
view(0,90)
colormap turbo
a = colorbar('eastoutside');
Now I would like to insert a contour plot, also imported from a comsol data matrix in the same format, above the surface plot. I have tried several ways but haven't gotten good results. Can someone help me? Thanks in advance
  댓글 수: 2
Adam Danz
Adam Danz 2021년 11월 19일
Please attach Comsol_surf.txt
Tomas Altea
Tomas Altea 2021년 11월 22일
I've attached it now, sorry for the wait

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

채택된 답변

KSSV
KSSV 2021년 11월 22일
A = load('Comsol_surf.txt');
x = A(:,1);
y = A(:,2);
z = A(:,3);
%
xg = linspace(min(x),max(x),1000) ;
yg = linspace(min(y),max(y),1000) ;
[X,Y] = meshgrid(xg,yg) ;
Z = griddata(x,y,z,X,Y) ;
figure(1)
pcolor(X,Y,Z)
shading interp
figure(2)
contour(X,Y,Z)
figure(3)
contourf(X,Y,Z)
figure(4)
surf(X,Y,Z)
shading interp
If you want to use contour on unstructured grid without converting it into a structured grid, you can use:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by