Plotting CFD data contour in matlab
이전 댓글 표시
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
Wan Ji
2021년 8월 18일
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
2021년 8월 18일
Attach your data.
Muhammad Atif
2021년 8월 18일
Nikhil Shinde
2022년 8월 19일
편집: Nikhil Shinde
2022년 8월 19일
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')
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



