# How can i run my integer number from this question ?

조회 수: 1(최근 30일)
MD HASIBUR RAHMAN LEMON 2020년 10월 1일
댓글: Walter Roberson 2020년 10월 1일
The question is :
Enter a character. If it is an uppercase letter, it outputs its
successor. If it is a lowercase letter, it outputs its leading character.
If it is another character, it will be output as it is.
Point to be noted , i want to execute the integer number with matlab function such as int8 , int16 like this . I'm going to share my code which i made. Can anyone help me to find the problem ?
My created code is :
inputLetter = input('Please input a string number : ','s');
if(inputLetter == upper(inputLetter))
fprintf( 'Its a successor!');
elseif (inputLetter == lower(inputLetter))
elseif(inputLetter == int16(inputLetter))
fprintf('Its is obvoiusly '+inputLetter);
else
fprintf('Incorrect input ! ');
end
##### 댓글 수: 7표시숨기기 이전 댓글 수: 6
Walter Roberson 2020년 10월 1일
You tested whether the input is an uppercase character by testing
if inputLetter == upper(inputLetter)
But when you take upper() of something that is not a letter, then the result is the same as the input -- upper('1') is the same as '1' .
I recommend you see isstrprop() if you want to get as far as supporting uppercase and lowercase Unicode characters.
If you only want to bother handling English, then I suggest you use ismember()

댓글을 달려면 로그인하십시오.

### 답변(1개)

You can convert the strinng to a double number then apply int8 or int16:
int16(str2double(inputLetter))

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by