Subscript indices must either be real positive integers or logicals. How to solve this error?

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
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)

Más respuestas (0)

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!

Translated by