フィルターのクリア

liste vertex into polyhedron

31 ビュー (過去 30 日間)
RICCARDO
RICCARDO 2024 年 8 月 13 日 18:19
編集済み: Matt J 2024 年 8 月 13 日 20:48
Can I list all vertexes of polyhedron into this format ?
Ax<=b
x>=0
A is matrix

採用された回答

Matt J
Matt J 2024 年 8 月 13 日 20:41
編集済み: Matt J 2024 年 8 月 13 日 20:48
See lcon2vert in this FEX download, which does not require the Optimization Toolbox,

その他の回答 (1 件)

Naga
Naga 2024 年 8 月 13 日 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

カテゴリ

Help Center および File ExchangeComputational Geometry についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by