Subscript indices must either be real positive integers or logicals. How to solve this error?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Darren
el 8 de Dic. de 2013
Respondida: Walter Roberson
el 8 de Dic. de 2013
Hi, I am given a question by my lecturer to convert ASCII character number to ASCII character. Basically, I got to write a script fulfilling a few conditions below.
Example: When input=65, disp The ASCII character of 65 is >A<
However there are some conditions, (a)If input=10, display Return. (b)If input>225, disp Value too high (c)If input is a negative value, take the modulus value of the negative value and convert it to ASCII character. (d)If input is an negative value exceeding -225, disp Error!
I managed to solve the above problems. However, the next question given in the coursework is I got to take condition(b)(c) and (d) and save it as an external function check_value.
The problem is, when I save it as an external function of check_value, it always print an error when I key in a negative value. * Subscript indices must either be real positive integers or logicals. *
How to stop this error? The thing is, I must key in a negative value without getting this error. And I have no idea how to solve this.
1 comentario
Respuesta aceptada
Walter Roberson
el 8 de Dic. de 2013
In your statement
value(i)=a;
you have not defined "i", so it has the MATLAB default value for "i", which is sqrt(-1)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!