MATLAB input function error; Output arguments.

2 visualizaciones (últimos 30 días)
Zane Gomes
Zane Gomes el 28 de Mzo. de 2021
Comentada: Zane Gomes el 28 de Mzo. de 2021
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 comentarios
per isakson
per isakson el 28 de Mzo. de 2021
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?
Zane Gomes
Zane Gomes el 28 de Mzo. de 2021
Editada: Zane Gomes el 28 de Mzo. de 2021
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.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 28 de Mzo. de 2021
Editada: Stephen23 el 28 de Mzo. de 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 comentarios
Stephen23
Stephen23 el 28 de Mzo. de 2021
Editada: Stephen23 el 28 de Mzo. de 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.
Zane Gomes
Zane Gomes el 28 de Mzo. de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by