How do I avoid the error : " assign output variable x0 for example has not been assigned a value" ?

Réponses (1)

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 commentaires

Hi, Thanks for the reply. What do you mean by move it outside? I attempted to do that but now I just get a new error saying not enough input arguments.
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 ?
I think the issue is I'm not sure what those variables in the function are supposed to mean all that well. But in any case I opened the script file and then in the command window I attempt to type in values for each of the inputs, but i think they are supposed to be a matrix of values but not sure if that's really the issue, but seems like it. Just wanted to rule out the issue being that I moved the x0 matrix in the script file to the wrong spot.

Connectez-vous pour commenter.

Commenté :

le 13 Nov 2022

Community Treasure Hunt

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

Start Hunting!

Translated by