MATLAB Answers

0

How to plot contour without interpolation on a nonuniform grid?

Asked by Yutong Li on 15 Jun 2019
Latest activity Answered by Star Strider
on 15 Jun 2019
Hi. The data I wish to plot (or post-process) is CFD data (vorticity, pressure, etc) from fluent. The grid is non-uniform, as the image shows, with a finner mesh near the square cavity.
Obviously I can use either 'scatteredinterpolate' or 'griddata' with a regenerated grid, like:
xmin = min(xx); xmax = max(xx);
ymin = min(yy); ymax = max(yy);
[x,y]=meshgrid(xmin:1e-3:xmax,ymin:1e-3:ymax);
vq = griddata(xx,yy,Vort,x,y);
However, I think this interpolation compromises the integrity of my data, since many details may be lost. I thought of using 'reshape', but since the grid is not non-uniform, this becomes very difficult. I attempted creating a uniform grid with lots of 'NaN' indicating no data. But plotting it just gave me no data at all. I have attached my code. The data is too big for attachment ~300Mb. Can someone please help? Much appreciated.

  0 Comments

Sign in to comment.

Products

1 Answer

Answer by Star Strider
on 15 Jun 2019

Have you experimented to see how contour (or contourf) works with your data? Did the function throw an error?
If not, just let contour (or contourf) loose on your data and see what the result is.
The function is reasonably robust.
Example:
x = randn(10);
y = randn(10);
z = randn(10);
figure
contourf(x, y, z, 'LineStyle','none')

  0 Comments

Sign in to comment.