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 Comments

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.

Sign in to comment.

 Accepted Answer

Stephen23
Stephen23 on 28 Mar 2021
Edited: Stephen23 on 28 Mar 2021
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 Comments

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?
Stephen23
Stephen23 on 28 Mar 2021
Edited: Stephen23 on 28 Mar 2021
"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.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020b

Asked:

on 28 Mar 2021

Commented:

on 28 Mar 2021

Community Treasure Hunt

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

Start Hunting!