output arguments not assigned
Mostra commenti meno recenti
Hello,
When I run this function
function [outcome] = days_of_the_week(day)
end
Output argument "outcome" (and maybe others) not assigned
Matlab says outcome argument not assigned (but still works despite this error)
BUT when I change [outcome] to [day]
function [day] = days_of_the_week(day)
end
The error goes away and the function works
Why?
Am I missing something obvious? Apologies, I am new to Matlab. Thank you.
Risposte (1)
David Hill
il 22 Ott 2019
0 voti
Because 'day' is the input variable, it is present in the function and will be passed to the output. the 'outcome' variable is never assigned in the function, so the error tells you that and nothing gets passed to the output. The error does not cause the function, which does nothing, not to work.
4 Commenti
David Hill
il 22 Ott 2019
Either is fine, but what is the purpose of your function?
Sarah K
il 22 Ott 2019
David Hill
il 22 Ott 2019
No, the output is generally a different named variable.
function [outcome] = name_of_function(input)
outcome=2*input;
end
Categorie
Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!