plotting a triangle with surf
18 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I have plotted a ellipsoid with the surf function and would like to add a triangle to this plot in a way, so that i can specify the height and length of the triangle.
Is this possible?
Thank you for your help!
0 件のコメント
採用された回答
Abhas
2024 年 11 月 25 日 14:17
Yes, you can add a triangle to your existing 3D plot in MATLAB. You can use the "patch" function to create a triangular surface by specifying the vertices of the triangle.
Here's an example to achieve the same:
[x, y, z] = ellipsoid(0, 0, 0, 5, 3, 2, 30);
figure;
surf(x, y, z);
hold on;
% You can adjust these coordinates to change the position, height, and length of the triangle
v1 = [1, 1, 1]; % Vertex 1
v2 = [4, 1, 1]; % Vertex 2
v3 = [1, 4, 3]; % Vertex 3
% Create the triangle using the patch function
patch('Vertices', [v1; v2; v3], 'Faces', [1, 2, 3], 'FaceColor', 'red', 'FaceAlpha', 0.5);
% Set the axis for better visualization
axis equal;
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Ellipsoid with a Triangle');
% Adjust view angle for better visualization
view(3);
You may refer to the below documentation links to know more about "patch": https://www.mathworks.com/help/matlab/ref/patch.html
I hope this helps!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!