Index exceeds matrix dimensions. Please help.
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
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.
Respuestas (1)
James Tursa
el 3 de Ag. de 2015
Editada: James Tursa
el 3 de Ag. de 2015
0 votos
Do you inadvertantly have a variable called "input" in your workspace?
4 comentarios
Derrick Edmiston
el 3 de Ag. de 2015
James Tursa
el 3 de Ag. de 2015
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
el 3 de Ag. de 2015
James Tursa
el 3 de Ag. de 2015
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.
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!