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