3D matrix and 3d plot in matlab

3 次查看(过去 30 天)
I want to use the repmat function to copy the velocity profile along a pipe for 30 times in order to make the geometry of pipe.
my code below generate the velocity profile for Poisuielle flow inside the pipe using meshgrid and mesh functions.
Please help me how to write the repmat to generate the pipe geometry.
R = 0.003/2; %pipe dia.
yy=linspace(-R,R,50);
xx=yy';
r=sqrt(xx.^2+yy.^2);%pipe redius as function of x , y
z=-(f1.a0)*(R^2-(xx.^2+yy.^2))/0.016;% velocity profile in z direction(along the pipe),f1.a0=constant
[X1,Y1]=meshgrid(xx,yy);
figure
mesh(X1,Y1,z)
colorbar
contour(X1,Y1,z)
  2 个评论
darova
darova 2020-5-20
Here is the result of your code
Can you explain more what are you trying to achieve?
darova
darova 2020-5-20
Can you make a simple sketch in paint?

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-5-20
f1.a0 = -3; %to have **some** value
R = 0.003/2; %pipe dia.
yy=linspace(-R,R,50);
xx=yy;
d = linspace(0,1,30); %distance along pipe
[XX,YY,DD] = meshgrid(xx, yy, d);
r = sqrt(XX.^2+YY.^2);%pipe redius as function of x , y
VV = -(f1.a0)*(R^2-(XX.^2+YY.^2))/0.016;% velocity profile in z direction(along the pipe)
levels = linspace(min(VV(:)), max(VV(:)), 10);
for K = 1 : length(levels)
isosurface(XX, YY, DD, VV, levels(K));
end
xlabel('x');
ylabel('y');
zlabel('distance along pipe');
title('velocity profile')
colorbar;
  3 个评论
Walter Roberson
Walter Roberson 2020-5-27
VV is the 3d array you asked for, under the assumption that the flow is the same at each distance along the pipe. The isosurface loop is for visualization that the geometry is as desired.
Walter Roberson
Walter Roberson 2020-6-2
I just noticed an unnecessary calculation. You never use the r you calculate. I suggest
r2 = XX.^2+YY.^2; %pipe radius squared as function of x , y
VV = -(f1.a0)*(R^2-r2)/0.016;% velocity profile in z direction(along the pipe)
This should not change the calculation.
With the code that uses x and y coordinates arranged in a square, the corners have negative velocity not 0. Are you trying to model a circular pipe? If so then I would suggest using polar coordinates.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by