mesh grid and mesh ploting

조회 수: 11 (최근 30일)
H-M
H-M 2020년 5월 5일
댓글: H-M 2020년 5월 6일
R = 0.003/2;
y=linspace(-1,1,30);
x=linspace(-1,1,30);
r.^2==x.^2+y.^2;
y=r./R;
a0=-6536;
z=a0*R^2*(1-y.^2)/0.016;
[X1,Y1]=meshgrid(x,y);
%zz=griddata(x,y,z,X1,Y1,'cubic');
figure
mesh(X1,Y1,z)
This is a simple poiseuelle flow in a pipe, my goal is to plot the velocity of flow(z) in 3D. R is the redius of pipe, x and y are inplane and z is the velocity along the pipe length. I get the error ' Error using mesh Z must be a matrix, not a scalar or vector.' How can I get the z as a matrix to resolve the error?
  댓글 수: 3
H-M
H-M 2020년 5월 5일
편집: H-M 2020년 5월 6일
David,
Since the geometry is circle (pipe) and x and y are set in the cicle cross section, I think I need to relate the distance from center of pipe (r) to x and y that is why I wrote r=sqrt(x.^2+y.^2).On the other hand y=r/R.I mean I need to impose to code that the shape is circle or pipe.I do not know how to relate x,y,r together to work properly in code.
Also I put z after the meshgrid but I get z as a vector yet.
I am not sure about what I am doing. If you have any idea please lead me. Thank you
David Hill
David Hill 2020년 5월 6일
Do you have the equations you are trying to model? Or are you creating the model yourself?

댓글을 달려면 로그인하십시오.

답변 (1개)

H-M
H-M 2020년 5월 6일
I just have the poiseuille velocity equation(z equation in my code) in a circular pipe and I am supposed to plot the velocity profile in 3D with meshgrid.
  댓글 수: 1
H-M
H-M 2020년 5월 6일
x and y are 30*30 matrix but z is 1*30 matrix. z should be a 30*30 matrix

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by