input appears to be a function and variable and exceeds the number of array elements???
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I'm trying to work on an assignment and I'm really confused on why I keep getting this exact error: Index exceeds the number of array elements. Index must not exceed 69.
input appears to be both a function and a variable. If this is unintentional, use 'clear input' to remove the variable 'input' from the workspace.
My teacher told me to try and make my string shorter and I did, but now it just says 26. I'm also extremely confused on why I keep getting the same error because I've used the input command before just like this and had no issues prior to this. Please help :( here is my code.It's not completely done but it's the fourth line with the income input that's giving me the error.
edit: NEVERMIND WE FOUND IT OUT! matlab was combining two of my variables so we seperated them using a comment string and it got fixed :D
% income inputs for the user
fprintf ('enter your yearly income:');
input ('enter your yearly income:.');
income = input ('enter yearly income:');
income_group_A = 50000;
income_group_B = 0;
if (group_A<50000)
group_A = ('You can qualify for the tax deduction based on income.');
elseif (group_A>50000)
group_A= ('You do not qualify for the tax deduction based on income.');
elseif (group_B)
group_B = ('You are younger than 18 and do not qualify for the tax deduction.');
end
% age inputs for the user
input = ('input your age to see if you qualify for the tax deduction.');
age = input ('enter your age:');
if (age>=18)
end
fprintf ('user age is %f');
0 件のコメント
回答 (1 件)
Torsten
2024 年 9 月 9 日
編集済み: Torsten
2024 年 9 月 9 日
You define a string of length 59 named "input". Then you want to use "input" as the MATLAB command to request user input for "age". But the MATLAB command was previously overwritten by the string. This throws an error.
input = ('input your age to see if you qualify for the tax deduction.')
input(59) % Request Character 59 of the string
age = input ('enter your age:') %input is a string in your code, not a matlab command to request user input.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Web Services についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!