![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/295278/image.png)
3D matrix and 3d plot in matlab
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
H-M
le 17 Mai 2020
Commenté : Walter Roberson
le 2 Juin 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 commentaires
darova
le 20 Mai 2020
Here is the result of your code
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/295278/image.png)
Can you explain more what are you trying to achieve?
Réponse acceptée
Walter Roberson
le 20 Mai 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 commentaires
Walter Roberson
le 27 Mai 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
le 2 Juin 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!