필터 지우기
필터 지우기

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 CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by