创建一个在Matlab中的3D速度数据切片图。

huangapple go评论59阅读模式
英文:

Create a slice plot of 3D velocity data in matlab

问题

我正在尝试在Matlab中创建一个切片图。我收到了一个错误消息,说“使用interp3时出错(第148行)。输入网格不是有效的MESHGRID。在切片(第103行)中出错vi = interp3(x,y,z,v,xi,yi,zi,method)。”按照设置方式,向量x、y、z和u将具有相同的尺寸。我不太确定如何解决这个错误,感谢任何意见。

% 定义x、y和z坐标
x = 0:1.95313:1000;
y = 0:1.95313:250;
z = 0:1.93798:250;
[y, x, z] = meshgrid(y, x, z);
u = sin(x) + sin(y) + z;

% 定义切片平面
xslice = 0;
yslice = 0;
zslice = 0;

% 创建切片图
slice(x, y, z, u, xslice, yslice, zslice);
view(3);
axis([0 1000 0 250 0 250]);
grid on;

shading interp;
xlabel('X');
ylabel('Y');
zlabel('Z');
title('三维速度矢量的切片图');
英文:

I am trying to create a slice plot in Matlab. I receive an error that says "Error using interp3 (line 148). Input grid is not a valid MESHGRID. Error in slice (line 103) vi = interp3(x,y,z,v,xi,yi,zi,method);". The way it is set up, the vectors x,y,z, and u, will share the same size. I am not entirely sure how to resolve this error and would appreciate any input.

% Define the x, y, and z coordinates
x = 0:1.95313:1000;
y = 0:1.95313:250;
z = 0:1.93798:250;
[y,x,z] = meshgrid(y,x,z);
u = sin(x) + sin(y) + z;

% Define the slice planes
xslice = 0;
yslice = 0;
zslice = 0;

% Create the slice plot
slice(x, y, z, u, xslice, yslice, zslice);
view(3);
axis([0 1000 0 250 0 250]);
grid on;

shading interp;
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Slice Plot of 3D Velocity Vector');

答案1

得分: 1

The mesh variables are swapped in your code. Define the grid in the order x, y, z and not y, x, z, as used later:

[x, y, z] = meshgrid(x, y, z);

英文:

The mesh variables are swapped in your code. Define the grid in the order x, y, z and not y, x, z, as used later:

[x,y,z] = meshgrid(x,y,z);

huangapple
  • 本文由 发表于 2023年4月11日 03:07:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定