How to use contourf with 1D data
Mostrar comentarios más antiguos
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 :-)
Respuestas (1)
darova
el 9 de Abr. de 2020
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 comentarios
Antoine Laterre
el 10 de Abr. de 2020
Lalit Duseja
el 29 de Jun. de 2022
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
el 29 de Jun. de 2022
Editada: Walter Roberson
el 29 de Jun. de 2022
Categorías
Más información sobre Gas Dynamics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
