Greetings, I want to ask about the error in line 10. E be the tetrahedron bounded by the planes x=0, y=0, z=0, x+y+z=2. I don't how to fix it. Any helps would be appreciated.
6 ビュー (過去 30 日間)
古いコメントを表示
syms x y z
xAxis = linspace(-1,2.5,1000);
yAxis = linspace(-1,2.5,1000);
zAxis = linspace(-1,2.5,1000);
[X, Y, Z] = meshgrid(xAxis,yAxis,zAxis);
f = x + y + z - 2;
x_planes = [0 2];
y_planes = [0 (2-x)];
z_planes = [0 (2-x-y)];
slice(X,Y,Z,f,x_planes,y_planes,z_planes);
0 件のコメント
回答 (1 件)
Arjun
2024 年 11 月 8 日 7:18
Hi @Diep,
I see that you want to use “slice” function of MATLAB for slicing your volumetric data.
The issue maybe because of the usage of symbolic variables in the code. The “slice” function requires numerical data to work and hence supplying it with symbolic data might be the cause of the error you are facing.
Kindly refer to the documentation of “slice” function: https://www.mathworks.com/help/releases/R2022a/matlab/ref/slice.html
Here is a corrected version of the code which you may find useful:
xAxis = linspace(-1, 2.5, 100);
yAxis = linspace(-1, 2.5, 100);
zAxis = linspace(-1, 2.5, 100);
[X, Y, Z] = meshgrid(xAxis, yAxis, zAxis);
V = X + Y + Z - 2;
% Define the planes where you want to take slices
x_planes = [0, 2];
y_planes = [0, 2];
z_planes = [0, 2];
% Plot the slices
figure;
slice(X, Y, Z, V, x_planes, y_planes, z_planes);
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Slices through the volume');
axis equal;
grid on;
view(3);
I hope this will help!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!