Streamslice for non-rectangular plane

8 views (last 30 days)
Andreas Frederiksen
Andreas Frederiksen on 9 May 2020
Answered: BhaTTa on 28 Nov 2024 at 4:23
When trying to plot the streamlines in a non-rectangular domain using the streamslice function, the streamslice function plots the streamlines in a rectangular domain which is defined by the corner-coordinates in X and Y. Any datapoints outside of this rectangular domain are not included, and any areas where there is no data is interpolated. Is there any way to specify the shape of the domain which the stramslice function should use when plotting the streamlines?
The following illustrates the problem.
figure
[X,Y] = meshgrid([0:4],[0:4]);
Ynew = Y + (X-2).^2;
streamslice(X,Ynew,ones(5,5),ones(5,5))
The domain is 'parabolic' but streamlines are plotted in a rectangular domain.

Answers (1)

BhaTTa
BhaTTa on 28 Nov 2024 at 4:23
Hey @Andreas Frederiksen, The streamslice function is designed to work with rectangular domains defined by the X and Y coordinate grids. When you have a non-rectangular domain, such as the parabolic domain created by transforming Y to Ynew, the function still operates within the bounding rectangle of the provided grid. Unfortunately, streamslice does not have built-in support for non-rectangular domains, but you can work around this limitation by using masking techniques to hide parts of the plot that fall outside your desired domain.
Here's how you can approach this problem:
1. Mask the Streamlines:
  • Plot the streamlines using streamslice.
  • Use masking to hide parts of the streamlines that fall outside your desired domain.
2. Custom Plotting:
  • Use stream2 to compute the streamlines manually and then selectively plot only those segments that lie within your desired domain.

Community Treasure Hunt

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

Start Hunting!