Input doesn't work
显示 更早的评论
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
采纳的回答
Image Analyst
2013-10-8
Don't call it input.m. input is the name of a built-in function. Call it something else, like myInput().
12 个评论
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
Rename /Users/Jzhang/Documents/MATLAB/input.m to /Users/Jzhang/Documents/MATLAB/myinput.m or something like that.
I tried that and it still doesn't work.
Okay now use
which -all input
and tell us what you get back.
so instead of radius=input('.....') use radius=which -all input('....') ?
no .. on the MATLAB command window, type
which -all input
it will show all the files with name input in your matlab path.
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
perfect... So rename the first file, to say 'troublesome.m'. Shadow effect will go. then run 'troublesome.m'
Hopefully your troubles will be gone.
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.
I'm sorry I'm a beginner at matlab. So rename input.m to troublesome.m?
nevermind, i got it. Thanks!
Then please mark this answer as "Accepted."
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
