MATLAB input function error; Output arguments.

The line of code is of the form:
line 23>Var_1 = input('prompt\n');
The error message is,
>Output argument "SA" (and maybe others) not assigned during call to "input".
>Error in %filename% (line 23)
If I'm not wrong, I have assigned a value to the output argument during the call to input, that being Var_1, right?
Could someone explain what might be the problem?
Exact code:
student_id_number = input('Enter students ID number:');
corresponding error message:
Output argument "SA" (and maybe others) not assigned during call to "input".
Error in lab4t5 (line 23)
student_id_number = input('Enter students ID number:');

2 个评论

I cannot reproduce the error you see (Win10/R2018b)
>> student_id_number = input('Enter students ID number:');
Enter students ID number:12345
>> student_id_number
student_id_number =
12345
The variable, SA, what's that?
I don't know what 'SA' is, it is nowhere in the .m file
I tried running the code section in the command prompt in stead of from the editor but got the same error.
I then copy and pasted your
>> student_id_number = input('Enter students ID number:');
into my command prompt incase i had made some syntak error but I am still getting the same Error, even if I run ot in the command prompt after I use close all; cler all; clc.
(see linked .png)
And thank you for giving time to my question.

请先登录,再进行评论。

 采纳的回答

You have created/added a function with name input, which shadows the inbuilt input function.
Use which to find the location of your input function/s:
which input -all
Delete or rename your input function/s. In future, do NOT name functions with the same name as inbuilt functions.

3 个评论

Thank you.
This really helps alot, I faintly remember creating a function named input.
But dosen't the user created functions need to be located in the same directory as the m file being run for this to be a problrm?
"But dosen't the user created functions need to be located in the same directory to be able to be called in an m file?"
No.
In order to be called from anywhere, functions must be on the MATLAB Search Path (or in the current directory). They are processed in the order that they are found on the Search Path:
In some very specific cases (e.g. private functions) there are further restrictions on where a function can be called from (but nothing like only "in the same directory" that I can recall).
Please remember to accept my answer if it resolves your original question.
Ok, thanks for providing the link to the search path information, I will go through it.
Thank you for the quick reply and extinsive clarification of my doubt.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by