3D matrix and 3d plot in matlab

3 visualizzazioni (ultimi 30 giorni)
H-M
H-M il 17 Mag 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 Commenti
darova
darova il 20 Mag 2020
Here is the result of your code
Can you explain more what are you trying to achieve?
darova
darova il 20 Mag 2020
Can you make a simple sketch in paint?

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 20 Mag 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 Commenti
Walter Roberson
Walter Roberson il 27 Mag 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 il 2 Giu 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by