Complied code not working

3 views (last 30 days)
Murray Forbes
Murray Forbes on 8 Jul 2014
Answered: Image Analyst on 8 Jul 2014
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.

Accepted Answer

Image Analyst
Image Analyst on 8 Jul 2014
They're probably entering more than one character. Try this:
City = upper(City(1));

More Answers (0)

Community Treasure Hunt

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

Start Hunting!