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')

 채택된 답변

Chad Greene
Chad Greene 2014년 11월 24일
편집: Chad Greene 2014년 11월 24일

0 개 추천

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)))

추가 답변 (1개)

Massimiliano
Massimiliano 2014년 11월 29일

0 개 추천

Thank you very much, it works!

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2014년 11월 24일

댓글:

2014년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by