How to use contourf with 1D data
이전 댓글 표시
Hello,
I'm using the method of characteristics to solve 2D supersonic flows inside a nozzle. The discrete solution is thus computed on n different points inside the nozzle.
At the end of the process, I get :
x % a 1D vector (1 x n) of the x coordinates of the points where a solution is computed
y % a 1D vector (1 x n) of the y coordinates of the points where a solution is computed
M % a 1D vector (1 x n) of the Mach number of the flow at the corresponding [x,y] points
I'd like to depict the solution I have on a 2D plot using contourf to obtain something like that :

My problem is that I don't know how to use meshgrid or reshape to do so.
I also would like to use quiver to show the flow direction, but I logically face the same problem...
Can you help me ?
Thanks a lot :-)
답변 (1개)
darova
2020년 4월 9일
Use linspace and meshgrid to create regular mesh
xx = linspace(min(xdata),max(xdata),20);
yy = linspace(min(ydata),max(ydata),20);
[X,Y] = meshgrid(xx,yy);

Use griddata to calculate value at each grid point
Z = griddata(xdata,ydata,zdata,X,Y);

And finally use contour to create contour

댓글 수: 3
Antoine Laterre
2020년 4월 10일
Lalit Duseja
2022년 6월 29일
Antoine Laterre can you share the code or guide me how you did this. I have a smilar problem. The diameter varies along x and I have to plot the temperature contours.
Antoine Laterre
2022년 6월 29일
편집: Walter Roberson
2022년 6월 29일
카테고리
도움말 센터 및 File Exchange에서 Gas Dynamics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
