How to plot matlab stream plot?
27 ビュー (過去 30 日間)
古いコメントを表示
I have a 2D domain which has diffrent width(X) and length(Y) as attached photo. Say the height Y=0.05 and width X=0.02;
I have each particle position array in X,Y and I know the corresponding velocity of the particle in U and V.
If I create meashgrid say
[X1,Y1] = meshgrid(0:0.005:0.02,0:0.005:0.05);
Then how I create the dimension of U and V equal to the dimension of X1 and Y1? So that I can plot
streamline(X1,Y1,U,V)
Please help,Thanks.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/681668/image.png)
0 件のコメント
採用された回答
Walter Roberson
2021 年 7 月 12 日
U1 = interp2(X, Y, U, X1, Y1);
V1 = interp2(X, Y, V, X1, Y1);
streamline(X1, Y1, U1, V1);
13 件のコメント
Walter Roberson
2021 年 8 月 5 日
編集済み: Walter Roberson
2021 年 8 月 5 日
You can do a bit better by calling stream2() yourself, see the first example at
The idea is that you would filter down your coordinates. For example break up into two blocks, one the left area and the other the bottom area, so that you avoid doing all that interpolation for the large part of your plot that is empty.
It might take a bit of work to figure out where the useful boundaries are given only the scattered data. One approach would be a crude 2d histogram to find out which parts are occupied.
By the way, I just opened a case recommending specific performance improvements to streamline(). I doubt we will see them before 2022 however.
その他の回答 (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!