Plotting CFD data contour in matlab
Afficher commentaires plus anciens
Hi,
I have imported CFD data into matlab and I can see x,y,z and U column in my data and I seperate them in a column matrix. I want to plot the contour of this data. I am cluless here. I have tried many approaches. To my understanding about plotting a contour:
step1: plot x and y according to grid size(n) required and draw a meshgrid. [X,Y]=meshgrid(x,y). this will generate X and Y of n by n.
Step 2: constuct "V" of n by n matrix of velocity by rearranging the data.
Step 3: Plot contour using pcolor(x,y,V) or contour(x,y,V)
However I am stuck on step2 how to convert V into n by n order. I used reshape() function which is giving error (Index in position 1 is invalid. Array indices must be positive integers or logical values.
U_reshaped= reshape(U(zeros(200^2,1), X(:), Y(:)), [200 200]); % I want 200 by 200 however size of my U is only 33000 by 1. I have seen this line used by one code which is working fine in his code in this format. but when I am trying on my data it is giving me this error.
Is there any easy way to visualise data in Matlab or any help with this command. Thanks
4 commentaires
Wan Ji
le 18 Août 2021
Firstly you should tell whether your cfd model is 3d or 2d. From your question, x,y,z,U indicate that your model may be 3d.
KSSV
le 18 Août 2021
Attach your data.
Muhammad Atif
le 18 Août 2021
Nikhil Shinde
le 19 Août 2022
Modifié(e) : Nikhil Shinde
le 19 Août 2022
Please take a look at Delaunay and Trisurf functions in matlab. Extract your vertices data in a matrix. Following is the code that I used in my posprocessing assignment, You can tailor it according to your needs
vel_files = dir('*.csv'); %Only velocity data
velnum = length(vel_files);
vel_data = cell(1, velnum);
for k = 1:velnum-1
filename = vel_files(k).name;
vel_data{k} = readmatrix(filename);
end
Tvert = readtable('vertices.csv'); %vertices data
x = Tvert.Var1;
y = Tvert.Var2;
vertices= cat(2,x ,y);
DT = delaunay(vertices);% Delaunay Triangulation
VELALL=cell2mat(vel_data); trisurf(DT,vertices(:,1),vertices(:,2),VELALL(:,141),'EdgeColor','none'); axis tight; daspect([1 1 1]); shading interp; colormap jet; view(2);title('Ux t=100s')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Contour Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



