How to use contourf with 1D data
64 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 :-)
0 commentaires
Réponses (1)
darova
le 9 Avr 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 commentaires
Lalit Duseja
le 29 Juin 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
le 29 Juin 2022
Modifié(e) : Walter Roberson
le 29 Juin 2022
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!