how can I plot fluid through the cylinders

조회 수: 3 (최근 30일)
Shreen El-Sapa
Shreen El-Sapa 2023년 11월 21일
답변: Shlok 2025년 5월 30일
%t = 0:pi/18:2*pi; y=0:.01:3;x=0:.01:3;
t = 0:pi/20:2*pi; y=0:.01:5;x=0:.01:5;
%[X,Y,Z] = cylinder(.8*(1+.06*sin(5*t)));
[X,Y,Z] = cylinder(.8*(1+.06*sin(5*t)));
surfl(X,Z,Y)
hold on
%[X,Y,Z] = cylinder(1.8*(1+.06*sin(5*t)));
[X,Y,Z] = cylinder(1.8*(1+.06*sin(5*t)));
surfl(X,Z,Y)
%title('$\lambda=5,\epsilon=0.06$','Interpreter','latex','FontSize',11,'FontName','TiemsNewRoman','FontWeight','Normal');
shading interp
colormap(gray);
axis square
axis off

답변 (1개)

Shlok
Shlok 2025년 5월 30일
Hi Shreen,
To illustrate fluid flow within the cylindrical geometry, an effective approach is to introduce an inner cylinder that represents the fluid. This inner core can be visually distinguished using a different colormap and some transparency, helping it stand out from the outer structure.
For example:
t = 0:pi/20:2*pi;
[Xf, Yf, Zf] = cylinder(0.6 * (1 + 0.06 * sin(5 * t)));
Zf = Zf * 3;
fluid = surf(Xf, Yf, Zf, Zf, 'FaceAlpha', 0.6, 'EdgeColor', 'none');
axis off
To enhance the visualization and simulate fluid motion, animate the inner surface by gradually shifting the phase of the sine wave. This creates a wave-like effect, simulating fluid movement inside the cylinder:
for k = 1:100
[Xf, Yf, Zf] = cylinder(0.6 * (1 + 0.06 * sin(5 * t + 0.1 * k)));
Zf = Zf * 3;
set(fluid, 'XData', Xf, 'YData', Yf, 'ZData', Zf, 'CData', Zf);
drawnow;
end
For more information about the "cylinder" function, refer to the following MathWorks documentation link:

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by