필터 지우기
필터 지우기

Output argument 'check_equal' is not assigned on some execution paths

조회 수: 1 (최근 30일)
This is the main function
Main_algo.m
x=7;
y=7;
check_equal_case(x,y)
it is called from function: check_equal_case.m
function check_equal=check_equal_case(x,y)
if (x==y)
final_seq = ones(1,y)
end
compilation is correct in matlab script.
when try to generate c ++ code, matlab throws error : Output argument 'check_equal' is not assigned on some execution paths
please help.

채택된 답변

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020년 1월 10일
This is because output variable should have a value in each execution branch. Otherwise MATLAB Coder compiler will not be able to determine the value of the output when that branch is taken.
One potential soution for this issue is to initialize the output variable at the beginning of the function :
function check_equal=check_equal_case(x,y)
check_equal = false;
if (x==y)
final_seq = ones(1,y)
end
end
If the output variable is changing it's size in some of the branches, then you can make use of coder.varsize :
function [x,y] = usevarsize(n)
%#codegen
x = 1;
coder.varsize('x');
y = size(x);
if n > 10
x = 1:10;
end
Hope this will help you.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by