Azzera filtri
Azzera filtri

liste vertex into polyhedron

31 visualizzazioni (ultimi 30 giorni)
RICCARDO
RICCARDO il 13 Ago 2024 alle 18:19
Modificato: Matt J il 13 Ago 2024 alle 20:48
Can I list all vertexes of polyhedron into this format ?
Ax<=b
x>=0
A is matrix

Risposta accettata

Matt J
Matt J il 13 Ago 2024 alle 20:41
Modificato: Matt J il 13 Ago 2024 alle 20:48
See lcon2vert in this FEX download, which does not require the Optimization Toolbox,

Più risposte (1)

Naga
Naga il 13 Ago 2024 alle 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

Categorie

Scopri di più su Computational Geometry in Help Center e File Exchange

Prodotti


Release

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by