I was working on writing a script but when I included the input function I received the following error: Attempt to execute SCRIPT input as a function: /Users/Jzhang/Documents/MATLAB/input.m Error in circle_area (line 2) radius=input('Enter the radius:'); I've tried the input function in other scripts as well and they were working before but not anymore. Can anyone help me figure out this problem? Thanks

 Respuesta aceptada

Image Analyst
Image Analyst el 8 de Oct. de 2013

0 votos

Don't call it input.m. input is the name of a built-in function. Call it something else, like myInput().

12 comentarios

Jerry
Jerry el 8 de Oct. de 2013
I understand that input.m is a name of a built-in-function. For this example I wanted the user to input a number for the radius, so i wrote radius=input('Please enter the radius:'). However that didn't work
Image Analyst
Image Analyst el 8 de Oct. de 2013
Rename /Users/Jzhang/Documents/MATLAB/input.m to /Users/Jzhang/Documents/MATLAB/myinput.m or something like that.
Jerry
Jerry el 8 de Oct. de 2013
I tried that and it still doesn't work.
Walter Roberson
Walter Roberson el 8 de Oct. de 2013
Okay now use
which -all input
and tell us what you get back.
Jerry
Jerry el 8 de Oct. de 2013
so instead of radius=input('.....') use radius=which -all input('....') ?
ES
ES el 8 de Oct. de 2013
no .. on the MATLAB command window, type
which -all input
it will show all the files with name input in your matlab path.
Jerry
Jerry el 8 de Oct. de 2013
oh i see, i got the following: >> which -all input /Users/Jzhang/Documents/MATLAB/input.m built-in (/Applications/MATLAB_R2013b.app/toolbox/matlab/lang/input) % Shadowed
ES
ES el 8 de Oct. de 2013
perfect... So rename the first file, to say 'troublesome.m'. Shadow effect will go. then run 'troublesome.m'
Hopefully your troubles will be gone.
Walter Roberson
Walter Roberson el 8 de Oct. de 2013
That would not have happened if you had done the renaming that Image Analyst suggested. Though you might have needed to use the command
clear input
after you did the rename.
Jerry
Jerry el 8 de Oct. de 2013
I'm sorry I'm a beginner at matlab. So rename input.m to troublesome.m?
Jerry
Jerry el 8 de Oct. de 2013
nevermind, i got it. Thanks!
Image Analyst
Image Analyst el 8 de Oct. de 2013
Then please mark this answer as "Accepted."

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Oct. de 2013

Comentada:

el 8 de Oct. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by