Function 'boundary' not supported for code generation. How to solve this?

조회 수: 4 (최근 30일)
Yueqian Liang
Yueqian Liang 2025년 1월 17일
답변: Mathieu NOE 2025년 1월 20일
Function boundary(), which is used to get the boundary of a set of points, does not support code generation. When I use coder to generate C++ code, error occurs. How to solve this problem?

답변 (1개)

Mathieu NOE
Mathieu NOE 2025년 1월 20일
hello
based on code seen here :
you can try this as an alternative to boundary :
function [x_out,y_out] = tight_boundary(x,y)
%https://fr.mathworks.com/matlabcentral/answers/299796-tight-boundary-around-a-set-of-points
%split data into classes and find max/min for each class
class_label = unique(x);
upper_boundary = zeros(size(class_label));
lower_boundary = zeros(size(class_label));
for idx = 1:numel(class_label)
class = y(x == class_label(idx));
upper_boundary(idx) = max(class);
lower_boundary(idx) = min(class);
end
left_boundary = y(x == class_label(1));
right_boundary = y(x == class_label(end));
% left_boundary
x1 = class_label(1)*ones(size(left_boundary));
y1 = left_boundary;
% right_boundary
x2 = class_label(end)*ones(size(right_boundary));
y2 = right_boundary;
% top boundary
x3 = class_label;
y3 = upper_boundary;
% bottom boundary
x4 = class_label;
y4 = lower_boundary;
x_out = [x1(:);x2(:);x3(:);x4(:);];
y_out = [y1(:);y2(:);y3(:);y4(:);];
end

카테고리

Help CenterFile Exchange에서 Linear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by