Input function does not display the command in command window

7 ビュー (過去 30 日間)
Austin DeSpain
Austin DeSpain 2019 年 4 月 18 日
コメント済み: Austin DeSpain 2019 年 4 月 18 日
I am new to MATLAB and cannot figure out what I am doing wrong.
When writing script, I use the input function. For example:
%this function can be used to tell if one is eligible to drive.
age = input('Enter your age: ')
if age<16
disp('sorry, you are not eligible.')
else
disp('yes, you are eligible')
end
When I Run the script, MATLAB automatically generates a random matrix consisting of numbers:
>> Untitled2
age =
Columns 1 through 9
4761 12100 13456 10201 12996 1024 14641 12321 13689
Columns 10 through 16
12996 1024 9409 10609 10201 3364 1024
yes, you are eligible
>>
I am not sure what I am doing wrong, could someone help me out?
  2 件のコメント
madhan ravi
madhan ravi 2019 年 4 月 18 日
which input -all % what show up?
Austin DeSpain
Austin DeSpain 2019 年 4 月 18 日
>> which input -all %
C:\Users\Austin\Desktop\programmin\.m files\input.m
built-in (C:\Users\Austin\Desktop\MATLAB stuff\toolbox\matlab\lang\input) % Shadowed

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2019 年 4 月 18 日
Looks like you have made a file named input.m remove it from the path or rename it.
  1 件のコメント
Austin DeSpain
Austin DeSpain 2019 年 4 月 18 日
That fixed it! Thank you! I am incredibly new to this, I appreciate your help. I just renamed the file and removed the current one from the path.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAdding custom doc についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by