3D matrix and 3d plot in matlab

4 visualizaciones (últimos 30 días)
H-M
H-M el 17 de Mayo de 2020
Comentada: Walter Roberson el 2 de Jun. de 2020
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 comentarios
darova
darova el 20 de Mayo de 2020
Here is the result of your code
Can you explain more what are you trying to achieve?
darova
darova el 20 de Mayo de 2020
Can you make a simple sketch in paint?

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Mayo de 2020
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 comentarios
Walter Roberson
Walter Roberson el 27 de Mayo de 2020
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 el 2 de Jun. de 2020
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by