Slicing 3D model data without using griddata
조회 수: 16 (최근 30일)
이전 댓글 표시
I'm trying to plot slices through quite large data sets (about 40K points at the moment, but probably at least 4 times that size in the future) which I receive in a specific output from my solver.
The data is output for each single timestep is a matrix (which I'm reading in from a txt file) like so:
NodeID NodePosX NodePosY NodePosZ VarA VarB VarC .....
1 0.2 0.1 0.1 1 1 2
2 0.3 0.1 0.3 4 0 2
where the can be many variables. The data is sorted by NodeID and not the x,y or z position.
What I want to be able to do is use subplot to display a few slices through the volume for any given variable for each timestep so that I have a full set of images to make a video with eventually.
Currently my approach is painfully slow:
- use meshgrid to define a even grid in all three directions based on the max and min values of the node positions
- use griddata to generate the volume data for the meshed grid for each variable I'm interested in
- use slice on a few planes in a subplot for each variable
This currently works....but it's terribly slow. Currently I have data for 250 timesteps and I tried running my script on it and it takes about 3-4 minutes per timestep, per variable. So I want to plot the results for 3 variables (say components of velocity) I can generate only 6 timesteps worth of data in an hour.
My bottleneck is having to go from the vector node data to a volume data using griddata, but I can't think of a better way of doing this for the format the data I receive is in. Is there a way to plot the data with scatter3 and then interpolate slices through that?
Any ideas on how to do this more efficiently would be appreciated. I can't think of a quicker way at the moment.
댓글 수: 0
답변 (1개)
Mike Garrity
2015년 8월 26일
You're inserting your data points into a 3D grid and then pulling a 2D slice out of that grid. That could make sense if you want to get a lot (most) of the slices from that 3D volume.
But if you're only getting a few slices, it would probably make more sense to take a subset of your data points which are in (near) your slice, and insert those into a 2D grid. Does that make sense?
댓글 수: 3
Mike Garrity
2015년 8월 26일
>> maybe increase the mask to z=22,23,24 and do some interpolation?
Yes, that's my guess. In areas where now datapoints fall in the slice, the 3D version is able to interpolate from the neighboring slices. But I don't think that you'll need a lot of slices to get the same effect.
I think this picture suggests that:
hold on
scatter(data(mask,1),data(mask,2), ...
[],data(mask,4),'filled', ...
'MarkerEdgeColor','black')
set(gca,'SortMethod','childorder')

참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!