plotting a triangle with surf
18 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Carsten
il 25 Nov 2024 alle 14:08
Commentato: Carsten
il 25 Nov 2024 alle 14:40
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 Commenti
Risposta accettata
Abhas
il 25 Nov 2024 alle 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!
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Lighting, Transparency, and Shading 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!