So here's my function:
[x,y] = meshgrid(-2:0.2:2);
hold all
dy = (x.^3+y)./(x.^2+y.^2) ;
norm = sqrt(dy.^2+1^2);
quiver(x, y, ones(size(x))./norm,dy./norm,0.75)
startx = -2:0.2:2; %Streamlines
starty = 0.*ones(size(startx));
streamline(x, y, ones(size(x))./norm,dy./norm,startx,starty)
looks pretty decent, but I wish to know how I can plot stream lines starting at each y-values that are 0.2 unity apart from each other. The code above just plots streamlines origining at 0.

 채택된 답변

Mischa Kim
Mischa Kim 2021년 1월 5일
편집: Mischa Kim 2021년 1월 5일

1 개 추천

Not entirely sure what you mean. Changing startx and starty values? In your code you set the starting values on the y-axis to 0.
starty = -2:0.2:2; %Streamlines
startx = -2.*ones(size(starty));

댓글 수: 4

Niklas Kurz
Niklas Kurz 2021년 1월 6일
편집: Niklas Kurz 2021년 1월 6일
Thank you for your suggestion. It's an interesting aproch and almost what I meant. The only thing that isn't in my favor is that there are still areas not filled with lines so I thought all areas will be perfused, if I plot something like
startx = -2:0.2:2;
starty = 0.*ones(size(startx)); %start at 0
...
startx = -2:0.2:2;
starty = 0.2*ones(size(startx)); %start at 0.2
...
startx = -2:0.2:2;
starty = 0.4*ones(size(startx)); %start at 0.4
...
but this seems just too fuzzy for me. So isn't there a short-cut?
I also tried your method combined with mine:
starty = -2:0.2:2; %y-direction
startx = -2.*ones(size(starty));
...
startx = -2:0.2:2; %x-direction
starty = -2.*ones(size(startx));
...
but didn't yield the result
To get "all areas filled" you could just use the x-y grid as starting points for the streamlines.
streamline(x, y, ones(size(x))./norm,dy./norm,x,y)
Alternatively, you can also create a separate starting points grid, e.g.
[Xs,Ys] = meshgrid(-2:0.4:2);
%...
streamline(x, y, ones(size(x))./norm,dy./norm,Xs,Ys)
Niklas Kurz
Niklas Kurz 2021년 1월 6일
thank you, that's exactly what I wanted. I didn't got used to meshgrid in a wider spectrum yet, but this case helps me to do so.
Niklas Kurz
Niklas Kurz 2021년 1월 6일
편집: Niklas Kurz 2021년 1월 6일
One little nuance: Do u know how I set opacity of streamline? I tried patchline add-on and whatnot, but doesn't seem to work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

질문:

2021년 1월 5일

편집:

2021년 1월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by