Plotting in 2D
- Plot the Equilateral Triangle (Simplex): You can plot an equilateral triangle by defining its vertices and using the plot function.
- Transform Probability Vectors: probability vectors (for 2D simplex, vectors of size 3 summing to 1) do not directly correspond to Cartesian coordinates, you'll need to transform them into the 2D space of the simplex.
- Plot Points: Use the transformed coordinates to plot points within the simplex.
vertices = [0, 0; 1, 0; 0.5, sqrt(3)/2];
vertices = [vertices; vertices(1,:)];
plot(vertices(:,1), vertices(:,2), '-');
P = [0.1, 0.6, 0.3; 0.3, 0.3, 0.4; 0.25, 0.25, 0.5];
title('2D Simplex with Points');
Extending to 3D
vertices = [0, 0, 0; 1, 0, 0; 0.5, sqrt(3)/2, 0; 0.5, sqrt(3)/6, sqrt(2/3)];
faces = [1, 2, 3; 1, 2, 4; 2, 3, 4; 1, 3, 4];
trisurf(faces, vertices(:,1), vertices(:,2), vertices(:,3), 'FaceColor', 'none', 'EdgeColor', 'b');
P = [0.1, 0.2, 0.3, 0.4; 0.25, 0.25, 0.25, 0.25];
x = P(i,1) + P(i,2)/2 + P(i,4)/3;
y = P(i,2)*sqrt(3)/2 + P(i,4)*sqrt(3)/6;
title('3D Simplex with Points');
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.