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

1 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2013-12-8
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 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by