How do I avoid the error : " assign output variable x0 for example has not been assigned a value" ?
이전 댓글 표시
I'm having problems getting this code to run. How do I ensure values are assigned for both inputs and outputs to have a successfully generated code?
답변 (1개)
Walter Roberson
2022년 11월 13일
편집: Walter Roberson
2022년 11월 13일
If you are looking at function sf_bioc then it only assigns a value to x0 in the case that flag == 0. Code generation needs there to be an assignment to the function in all cases. The easiest way to do that is to move the assignment to x0 to outside of the if statement.
Side note:
if abs(flag == 1)
is odd code. logical comparisons can never return negative numbers, so abs() of them is pointless except in-so-far as it effectively converts the logical to double.
I would understand if the code had been
if abs(flag) == 1
though I do not know at the moment whether the flag value can be -1 ever.
댓글 수: 3
Ryan Fraser
2022년 11월 13일
Walter Roberson
2022년 11월 13일
Is the error about not enough input arguments at the time you are doing code generation? If so then how are you doing code generation ?
Ryan Fraser
2022년 11월 13일
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!