How can I plot the streamlines in all region around the inside sphere ?

 채택된 답변

Star Strider
Star Strider 2024년 1월 2일
편집: Star Strider 2024년 1월 2일

1 개 추천

One approach is to change the code to add a patch object in this part of it (add ‘pv’ and ‘cv’ and the patch call):
set(polar(th,r1,'-k'),'LineWidth',1.2);set(polar(th,r2,'-k'),'LineWidth',1.2);
pv = linspace(0, 2*pi*1.01, 250); % Used in 'patch'
cv = [cos(pv); sin(pv)]; % Used in 'patch'
patch(cv(1,:), cv(2,:), 'w') % Plot 'patch'
title('$\eta_1=\eta_2=0.0$','Interpreter','latex','FontSize',9,'FontName','Times New Roman','FontWeight','Normal')
First, delete (or comment-out) these lines:
if ~isempty(I);
x(I,J) = 0;
y(I,J) = 0;
end
They create the centre square, and you need to get rid of it.
This plots everything, then creates a white patch object for the inside circle to cover the contour lines in it. (An alternative would be to get all the contour coordinates from ‘DH1’ and then delete the (x,y) pairs that are inside the inner circle, defined here by the patch coordinates ‘pv’ and ‘cv’. That could be done, however it would significantly slow the code. Creating the patch object is just easier.)
(The entire code is too long to post, exceeding the maximum character limit.)
EDIT — (2 Jan 2024 at 22:20)
The result is something like this —
.

댓글 수: 6

Thanks so much. Can you send the code file after your modifications?
My pleasure!
I listed the only modifications that I made, and demonstrated where I put them in your code. (The patch call has to come after the contour call.) Those were adding the patch call (and its supporting data in the two lines preceeding it), and deleting that particular if block. I did not need to change anything else in your code (although I increased the number of contours to 200, since for whatever reason, only specifying 20 did not work for me).
Thanks so much it excuted. Now I need to fill the inside sphere with gry if you can help me.
My pleasure!
That is straightforward —
pv = linspace(0, 2*pi*1.01, 250); % Used in 'patch'
cv = [cos(pv); sin(pv)]; % Used in 'patch'
gryval = 0.5; % Controls Shading
patch(cv(1,:), cv(2,:), [1 1 1]*gryval) % Plot 'patch'
axis('equal')
axis('off')
Change ‘gryval’ (within the limits of 0 to 1) to control the ‘grayness’ of the circle. Experiment to get the result you want.
.
excellent, I appreciate you so much.
As always, my pleasure!

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

추가 답변 (1개)

Shreen El-Sapa
Shreen El-Sapa 2024년 1월 7일

0 개 추천

Dear Star,can I plot half circles only?

댓글 수: 6

Probably. What do you want to do?
It might be easiest to just mask-out (or cover) the part you do not want (similar to what I did with the centre circle), rather than significantly change the code. That could be done with a patch call (and perhaps some plot calls to connect the otherwise incomplete lines connecting the inner and outer circles).
That is likely easier than changing the original code.
I want to display half circles only.
I assume that you mean the upper half.
Change the final plot code to:
[DK,h4]=contour(x,y,real(psiH),300,'--b');
%[DH1,h1]=contour(x,y,psiH,200,'--b');
hold on
m1=100;
r1=ones(1,m1+1)*a;r2=ones(1,m1+1)./L;
th=[0:2*pi/m1:2*pi];
set(polar(th,r1,'-k'),'LineWidth',1.2);set(polar(th,r2,'-k'),'LineWidth',1.2);
pv = linspace(0, 2*pi*1.01, 250); % Used in 'patch'
cv = [cos(pv); sin(pv)]; % Used in 'patch'
gryval = 0.8; % Controls Shading
patch(cv(1,:), cv(2,:), [1 1 1]*gryval) % Plot 'patch'
xl = xlim + [-1 1]*0.01;
patch([xl flip(xl)], [[1 1]*min(ylim)-0.01 0 0], 'w', 'EdgeColor','none')
plot(xlim, [0 0], '-k')
title('$\eta_1=\eta_2=0.01$','Interpreter','latex','FontSize',12,'FontName','Times New Roman','FontWeight','Normal')
ylabel({'$R_H=0.1$';'$\lambda=2.0$';'$\varphi=1.0$';'$\xi=\xi^{\prime}=0.1$'},'Interpreter','latex','FontSize',12,'rot',360,'FontName','Times New Roman','FontWeight','Normal');
axis('equal')
axis('off')
It plots a white patch object over the lower half of the axes and uses a plot call to draw a black horizontal line on the upper edge of the patch object. That connects the circles.
See if that does what you want.
.
As always, my pleasure!

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

카테고리

태그

질문:

2024년 1월 2일

댓글:

2024년 1월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by