Effacer les filtres
Effacer les filtres

liste vertex into polyhedron

31 vues (au cours des 30 derniers jours)
RICCARDO
RICCARDO le 13 Août 2024 à 18:19
Modifié(e) : Matt J le 13 Août 2024 à 20:48
Can I list all vertexes of polyhedron into this format ?
Ax<=b
x>=0
A is matrix

Réponse acceptée

Matt J
Matt J le 13 Août 2024 à 20:41
Modifié(e) : Matt J le 13 Août 2024 à 20:48
See lcon2vert in this FEX download, which does not require the Optimization Toolbox,

Plus de réponses (1)

Naga
Naga le 13 Août 2024 à 19:30
Hello Riccardo,
I understand that you are trying to list all the vertices of a polyhedron in MATLAB by solving the system of inequalities Ax<=b and x>=0. MATLAB does not have a built-in function specifically for listing all vertices of a polyhedron, but you can use the `linprog` function to find vertices.
1. Define the Polyhedron: Start with the matrix \(A\) and vector \(b\) that define your polyhedron.
2. Use `linprog` to Find Vertices: You can use linear programming to find the vertices by solving optimization problems for each combination of constraints.
Here is a MATLAB script to list all the vertices of a polyhedron:
function vertices = findPolyhedronVertices(A, b)
% Number of variables
n = size(A, 2);
% All combinations of constraints
combs = nchoosek(1:size(A, 1), n);
% Initialize an empty array to store the vertices
vertices = [];
% Solve for each combination of constraints
for i = 1:size(combs, 1)
% Select the constraints
A_eq = A(combs(i, :), :);
b_eq = b(combs(i, :));
% Solve the linear system A_eq * x = b_eq
x = A_eq \ b_eq;
% Check if the solution is feasible
if all(A * x <= b) && all(x >= 0)
% Add the vertex to the list
vertices = [vertices, x];
end
end
% Remove duplicate vertices
vertices = unique(vertices', 'rows')';
end
% Example usage:
A = [1 1; 1 -1; -1 0; 0 -1];
b = [2; 1; 0; 0];
vertices = findPolyhedronVertices(A, b);
% Display vertices in a readable format
disp('Vertices of the polyhedron:');
for i = 1:size(vertices, 2)
fprintf('Vertex %d: (%.4f, %.4f)\n', i, vertices(1, i), vertices(2, i));
end

Catégories

En savoir plus sur Computational Geometry dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by