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

1 view (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Dec 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)

More Answers (0)

Categories

Find more on MATLAB Mobile Fundamentals in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!