How can I generate a Contour Plot from 1 column of Z data?

5 vues (au cours des 30 derniers jours)
Adam Harris
Adam Harris le 23 Mai 2022
Commenté : Voss le 23 Mai 2022
Hello World,
I have data (attached PKE_xy.txt) from a fluid dynamics simulation that I am trying to generate a contour plot for. The simulation was run with x and y resolution Nx = 225, Ny = 8 -- so the data has 1800 rows and 1 column (ie; 225*8=1800).
I've previously used the contour() plot function for data with 2 columns, but here I have only 1 column. Is it possible to contour this data?
Thanks!

Réponse acceptée

Voss
Voss le 23 Mai 2022
Modifié(e) : Voss le 23 Mai 2022
reshape the column vector to a matrix of the appropriate size, which is 8-by-225 (Ny-by-Nx). That can be done in two ways, and this way gives the more reasonable looking contour plot:
data = reshape(readmatrix('PKE_xy.txt'),[],8).'
data = 8×225
1.0e+03 * 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958 2.0958
% data = reshape(readmatrix('PKE_xy.txt'),8,[]) % the other way
Then make the contour:
contour(data) % x = 1:225 and y = 1:8 implied. use your x and y vectors here instead, i.e., contour(x,y,data)
  2 commentaires
Adam Harris
Adam Harris le 23 Mai 2022
Thank you so much!
Voss
Voss le 23 Mai 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by