Index exceeds matrix dimensions. Please help.
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Here is my code:
disp('Choose one of the following options:');
a1=0;
while(a1~=4)
disp('press 1 for enter sides and shape code:');
disp('press 2 for diplay area:');
disp('press 3 for diplay perimeter:');
disp('press 4 for exit:');
*a1=input('Please Enter Your Selection:');*
if (a1==1)
v1=input('Enter value of side1:');
v2=input('Enter value of side2:');
v3=input('Enter the shape code(t/T for triangle r/R for rectangle:','s');
r1=calcarea(v1,v2,v3);
r2=calcperim(v1,v2,v3);
end
if (a1==2)
disp(['The area is :',num2str(r1)]);
end
if (a1==3)
disp(['The perimeter is :',num2str(r2)]);
end
if (a1==4)
disp('Thank you for using Geometric calculator, Goodbye!');
end
end
The error says: Index exceeds matrix dimensions Error in a1= input('Please enter your selection:'); I have highlighted for convenience.
0 件のコメント
回答 (1 件)
James Tursa
2015 年 8 月 3 日
編集済み: James Tursa
2015 年 8 月 3 日
0 投票
Do you inadvertantly have a variable called "input" in your workspace?
4 件のコメント
Derrick Edmiston
2015 年 8 月 3 日
James Tursa
2015 年 8 月 3 日
You need to clear that "input" variable from the workspace so that MATLAB can call the "input" function. As it is now, when that line get executed MATLAB thinks you are trying to index into the variable called "input" ... MATLAB is not calling the "input" function which is what you want.
Derrick Edmiston
2015 年 8 月 3 日
James Tursa
2015 年 8 月 3 日
Are you sure? Type the following:
dbstop if error
Then run your code. When it pauses at the error, type "whos" at the command line to see what variables you have.
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!