3D matrix and 3d plot in matlab

조회 수: 3 (최근 30일)
H-M
H-M 2020년 5월 17일
댓글: Walter Roberson 2020년 6월 2일
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