stream lines for discrete data set of velocities
1 次查看(过去 30 天)
显示 更早的评论
I had a set of discrete points whose velocities are known and postions and velocities will change with time , I want to use the streamline function, but in that , the condition is that the data sets should be monotonic . Is there any way to obtain stream lines for discrete particle locations which changes with time .
0 个评论
采纳的回答
Bjorn Gustavsson
2019-10-18
Your question is a bit too vague. Or rather, the input-data you have is a bit vaguely described. The answer depends on how you'll specify that input...
If you have a reasonably low number of particles and their trajectories (something like ) you could simply go for a looped version of plot3, maybe something like:
clf
hold on
E_kin = squeeze(sum(v(:,1,:).^2,3));
g = (E_kin-min(E_kin))/(max(E_kin)-min(E_kin));
r = (r(:,1,1)-min(r(:,1,1)))/(max(r(:,1,1))-min(r(:,1,1)));
b = (r(:,1,2)-min(r(:,1,2)))/(max(r(:,1,2))-min(r(:,1,2)));
for i1 = num_particles:-1:1
ph(i1) = plot3(r(i1,:,1),r(i1,:,2),r(i1,:,3));
set(ph(i1),'color',[r(i1),g(i1),b(i1)])
end
That would plot the trajectories of all your particles in 3-D with the trajectories coloured according to their
initial x-y position (red and blue), and initial kinetic energy (green).
On the other hand that seems like such an obvious solution, so you might such a large number of particles that this doesnt work. For that perhaps you can use local averaged velocities, but that would involve a lot of looping:
for each time-step for each sub-volume, find all all particles inside, calculate their average velocity, when done with all subvolumes, you should be able to use streamline3, then on to next time-step
HTH
6 个评论
Bjorn Gustavsson
2019-10-26
If your nans on the edges of the grid this might be because of a "simple" reason: the griddata (and the triscatteredinterp-functions (TriScatteredinterp, scatteredinterp, etc)) typically returns interpolated values inside the convex hull of the points you have data at - outside of that region (area in 2-D, volume in 3-D) it would be an extrapolation. You can test different interpolation-methods and some of the functions allow you to explicitly chose extrapolation methods.
How to handle extrapolation in the general case I dont know.
As far as I understand these methods should not return nan inside the convex hull - unless you have a nan in the input-data.
HTH
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!