I have a matlab function that works fine inside the matlab environment, but gives an error message when run as a compiled program. Below is a code snippit about the location of the error message;
City = 'A';
while (City ~= 'W') && (City ~= 'L')
City = input('Enter ''W'' for Wellington, ''L'' for Lower Hutt > ', 's');
City = upper(City);
end; % while
The following is the error message when run in a Windows (Win 7 64 bit) shell;
Enter 'W' for Wellington, 'L' for Lower Hutt > W
Operands to the || and && operators must be convertible to logical scalar values
.
Error in erosionimages (line 91)
MATLAB:nonLogicalConditional
Clearly the boolean condition is okay when first entering the while loop (otherwise I'd never get to the input line). I get the same result if I enter 'w', 'W', or 'x'. Line 91 is the end statement.

 採用された回答

Image Analyst
Image Analyst 2014 年 7 月 8 日

0 投票

They're probably entering more than one character. Try this:
City = upper(City(1));

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by