How can I make a selection of my streamlines?

4 views (last 30 days)
Hi everybody,
I use the command Streamlines to simulate the stream-flow of water in a porous media 3D. Now I want to view only the lines that crossing completely the cube (from left to right). How can I do?
Here it is the code I used
[sx,sy,sz]=meshgrid(10:5:nx-10,10:5:nx-10,10:5:nz-10);
hlines=streamline(1:nx,1:ny,1:nz,uy,ux,uz,sy,sx,sz);
set(hlines,'linewidth',2,'color','r')

Accepted Answer

Chad Greene
Chad Greene on 24 Nov 2014
Edited: Chad Greene on 24 Nov 2014
Try running the code below. It plots all streamlines, then loops through each streamline asking, "does this streamline's x data pass through 85 and 130?" If yes, it changes the streamlines to red.
load wind
[sx,sy,sz] = meshgrid(80,20:10:50,0:5:15);
h = streamline(x,y,z,u,v,w,sx,sy,sz);
view(3)
xlabel('x direction')
ylabel('y direction')
% preallocate an array of streamline indices that we'll later deem
% interesting:
ind = zeros(size(h));
for k = 1:length(h); % essentially, for each stream line.
xk = get(h(k),'xdata'); % get its x data
if min(xk)<=85 & max(xk)>=130;
ind(k)=1;
end
end
% set qualifying streamlines to red.
set(h(logical(ind)),'color','red')
You could similarly delete non-qualifying streamlines with
delete(h(~logical(ind)))

More Answers (1)

Massimiliano
Massimiliano on 29 Nov 2014
Thank you very much, it works!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!