Invalid Matrix Dimensions Error with frprintf
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Adam
el 27 de Oct. de 2014
Comentada: Adam
el 28 de Oct. de 2014
The following code returns the error after it (ignore the "if true % code end" part):
if true
% code
end
%%%%%%%%%_CODE_%%%%%%%%%
playORquit=5
if playORquit ~= 1
fprintf('THANK YOU FOR PLAYING GUESS-TRON!\n');
fprintf('Here are your results...\n');
fprintf('Number of Trials: %d\n', trial);
end
%%%%%%%%%_ERROR_%%%%%%%%%
Index exceeds matrix dimensions.
Error in TEST_youcandelete (line 2)
fprintf('THANK YOU FOR PLAYING GUESS-TRON!\n');
%%%%%%%%%%%%%%%%%%%%%%%%%
How do I have those strings printed if 'playORquit' doesn't equal '1'
1 comentario
Star Strider
el 27 de Oct. de 2014
The entire if-block and enclosed statements execute without error for me with ‘playORquit=5’, and setting ‘playORquit=1’ results in their not being executed. I don’t see the error.
Respuesta aceptada
Siddharth Sundar
el 28 de Oct. de 2014
Nothing in the above code seems to point towards any error. You might have a variable called fprintf defined in your workspace, causing MATLAB to recognize fprintf to be a matrix you are trying to index into with your fprintf statement. Please check this and use a different variable name if you do have a variable called fprintf.
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!